Submission #79244


ソースコード

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
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i = 0;i < n;i++){
scanf("%d",&a[i]);
}
int q;
scanf("%d",&q);
for(int i = 0;i < q;i++){
int x;
scanf("%d",&x);
int l = -1,r = n,k;
//x未満の数を求める
while(r-l > 1){
int mid = (l+r)/2;
if(a[mid] >= x){
r = mid;
}else{
l = mid;
}
}
k = r;
l = -1,r = n;
//x以下の数を求める
while(r-l > 1){
int mid = (l+r)/2;
if(a[mid] > x){
r = mid;
}else{
l = mid;
}
}
//x以下の数-x未満の数=xの個数
printf("%d\n",r-k);
}
}

ステータス

項目 データ
問題 0948 - Number-Collection
ユーザー名 ei2332
投稿日時 2024-05-28 08:39:29
言語 C
状態 Accepted
得点 10
ソースコード長 618 Byte
最大実行時間 293 ms
最大メモリ使用量 19296 KB

セット

セット 得点 Cases
1 a_NQ-small 1 / 1 *E??
2 b_a-small-positive 1 / 1 *?E?
3 c_a-unique 3 / 3 *??E
4 d_ALL 5 / 5 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-sample1EEE AC 21 ms 504 KB
1
2
3
4
input-sample2E__ AC 18 ms 524 KB
1
4
input01EEE AC 15 ms 356 KB
1
2
3
4
input02EEE AC 18 ms 400 KB
1
2
3
4
input03E__ AC 19 ms 424 KB
1
4
input04E__ AC 22 ms 476 KB
1
4
input05E__ AC 27 ms 528 KB
1
4
input06_E_ AC 143 ms 3776 KB
2
4
input07_E_ AC 171 ms 8560 KB
2
4
input08_E_ AC 229 ms 12184 KB
2
4
input09__E AC 293 ms 13636 KB
3
4
input10__E AC 161 ms 7232 KB
3
4
input11__E AC 219 ms 15412 KB
3
4
input12___ AC 112 ms 6992 KB
4
input13___ AC 132 ms 8736 KB
4
input14___ AC 104 ms 10320 KB
4
input15___ AC 274 ms 18296 KB
4
input16___ AC 256 ms 18800 KB
4
input17___ AC 261 ms 19296 KB
4
input18 AC 28 ms 7892 KB
4