Submission #60236


ソースコード

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 <stdio.h>
signed main(){
int n,p,i,t,q,temp,s;
int x[1000000],a[1000000];
scanf("%d",&n);
for(p=0;p<n;p++){
scanf("%d",&x[p]);
}
scanf("%d",&q);
for(t=0;t<q;t++){
scanf("%d",&a[t]);
}
for(t=0;t<q;t++){
int low=-1,high=n;
while(high-low>1){
int mid=(high+low)/2;
if(x[mid]<=a[t]){
low=mid;
}else{
high=mid;
}
}
printf("%d\n",low+1);
}
return(0);
}

ステータス

項目 データ
問題 0738 - プログラミング入門:二分探索
ユーザー名 ei2005
投稿日時 2020-06-24 17:55:27
言語 C
状態 Accepted
得点 10
ソースコード長 552 Byte
最大実行時間 102 ms
最大メモリ使用量 8824 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 62 ms 2524 KB
1
2
Input02 AC 22 ms 2572 KB
1
2
Input03 AC 15 ms 2620 KB
1
2
Input04 AC 25 ms 2408 KB
1
2
Input05 AC 21 ms 2452 KB
1
2
Input06 AC 102 ms 5952 KB
2
Input07 AC 97 ms 6200 KB
2
Input08 AC 88 ms 6712 KB
2
Input09 AC 94 ms 7364 KB
2
Input10 AC 93 ms 8824 KB
2