Submission #61172


ソースコード

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
///////高速化///////
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
///////////////////
////////変数宣言////////
long long n=0;
long long m=0;
long long t=0;
long long count=0;
long long high=0;
long long nowplace=-1;
long long find=0;
long long big=0;
///////////////////////
///////実行・出力////////////
cin >> n;
vector<long long> data(n,0);
for(int i=0;i<n;i++)
{
cin >> data[i];
}
sort(data.begin(),data.end());
cin >> m;
for(int i=0;i<m;i++)
{
cin >> t;
high=n;
nowplace=-1;
while(high-nowplace>1)
{
find=(nowplace+high)/2;
if(data[find]<=t)
{
nowplace=find;
}
else
{
high=find;
}
}
cout << nowplace+1 << endl;
}
return 0;
}

ステータス

項目 データ
問題 0738 - プログラミング入門:二分探索
ユーザー名 <span style="color:#000000;font-weight:bold;">ei2031</span>
投稿日時 2020-07-20 18:22:23
言語 C++17
状態 Accepted
得点 10
ソースコード長 1135 Byte
最大実行時間 287 ms
最大メモリ使用量 11296 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 22 ms 604 KB
1
2
Input02 AC 22 ms 560 KB
1
2
Input03 AC 18 ms 644 KB
1
2
Input04 AC 22 ms 604 KB
1
2
Input05 AC 23 ms 688 KB
1
2
Input06 AC 276 ms 8952 KB
2
Input07 AC 284 ms 9664 KB
2
Input08 AC 274 ms 10252 KB
2
Input09 AC 287 ms 10968 KB
2
Input10 AC 274 ms 11296 KB
2