Submission #77024


ソースコード

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
27
#include <bits/stdc++.h>
#define endl "\n"
#define INF INT_MAX
using namespace std;
bool check(char c,string s){
bool f = 0;
for(int i = 0;i < s.size();i++){
if(s[i] == c)f = 1;
}
return f;
}
int main(){
#define int long long
cin.tie(nullptr);ios::sync_with_stdio(false);
int n;
cin >>n;
vector<int>a(n);
for(int i = 0;i < n;i++)cin >>a[i];
int q;
cin >>q;
for(int i = 0;i < q;i++){
int y;
cin >>y;
int x = upper_bound(a.begin(),a.end(),y)-a.begin();
cout <<x<<endl;
}
}

ステータス

項目 データ
問題 0738 - プログラミング入門:二分探索
ユーザー名 ei2332
投稿日時 2023-10-25 15:53:03
言語 C++17
状態 Accepted
得点 10
ソースコード長 504 Byte
最大実行時間 172 ms
最大メモリ使用量 51576 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 49 ms 476 KB
1
2
Input02 AC 22 ms 428 KB
1
2
Input03 AC 23 ms 384 KB
1
2
Input04 AC 22 ms 596 KB
1
2
Input05 AC 22 ms 680 KB
1
2
Input06 AC 172 ms 18412 KB
2
Input07 AC 141 ms 28336 KB
2
Input08 AC 147 ms 36212 KB
2
Input09 AC 125 ms 44464 KB
2
Input10 AC 106 ms 51576 KB
2