Submission #79053


ソースコード

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<stdio.h>
int main(){
long long n,m,max,min,mid;
scanf("%lld",&n);
long long d[n+1];
d[0]=0;
for(int c=1; c<=n; c++){
scanf("%lld",&d[c]);
}
scanf("%lld",&m);
long long t;
for(int c=0; c!=m; c++){
scanf("%lld",&t);
min=0;
max=n+1;
while(1<(max-min)){
mid=(min+max)/2;
if(d[mid]<=t){
min=mid;
}else{
max=mid;
}
}
printf("%lld\n",min);
}
return(0);
}

ステータス

項目 データ
問題 0738 - プログラミング入門:二分探索
ユーザー名 ei2437
投稿日時 2024-05-24 16:37:27
言語 C
状態 Accepted
得点 10
ソースコード長 571 Byte
最大実行時間 106 ms
最大メモリ使用量 11044 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 24 ms 376 KB
1
2
Input02 AC 21 ms 520 KB
1
2
Input03 AC 22 ms 356 KB
1
2
Input04 AC 20 ms 376 KB
1
2
Input05 AC 20 ms 424 KB
1
2
Input06 AC 100 ms 8920 KB
2
Input07 AC 103 ms 9488 KB
2
Input08 AC 95 ms 10052 KB
2
Input09 AC 106 ms 10868 KB
2
Input10 AC 94 ms 11044 KB
2