Submission #64431


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<bits/stdc++.h>
using namespace std;
signed main(){
long long n;
cin>>n;
// vector<int> da(n+1,0);
long long data[n+1]={};
for(int i=0;i<n;i++){
cin>>data[i];
}
int m;
cin>>m;
long long t[m+1];
// vector<long long> t(m+1,0);
for(int i=0;i<m;i++){
cin>>t[i];
}
long long sum[m+1]={};
for(int i=0;i<m;i++){
// sum=upper_bound(data,data+n,t[i]);
sum[i]=upper_bound(data, data+n,t[i])-data;
cout<<sum[i]<<"\n";
}
//cout<<sum;
return(0);
}

ステータス

項目 データ
問題 0738 - プログラミング入門:二分探索
ユーザー名 ei2038
投稿日時 2020-10-22 18:12:18
言語 C++17
状態 Accepted
得点 10
ソースコード長 575 Byte
最大実行時間 284 ms
最大メモリ使用量 12784 KB

セット

セット 得点 Cases
1 Linear Search 2 / 2 Input0[1-5]
2 Binary Search 8 / 8 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 20 ms 604 KB
1
2
Input02 AC 20 ms 452 KB
1
2
Input03 AC 16 ms 556 KB
1
2
Input04 AC 19 ms 656 KB
1
2
Input05 AC 16 ms 632 KB
1
2
Input06 AC 281 ms 10568 KB
2
Input07 AC 284 ms 11152 KB
2
Input08 AC 241 ms 11744 KB
2
Input09 AC 244 ms 12588 KB
2
Input10 AC 239 ms 12784 KB
2