Submission #79233


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
string s="kariout.txt";
ofstream f(s);
int n;cin>>n;
int a[n+1];
a[0]=-9999999999;
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
int q;cin>>q;
while(q--){
int c;
scanf("%lld",&c);
int u,v,l,r;
//c-1 | c c|c+1
l=0,r=n+1;
while(r-l>1){
int mid=(l+r)/2;
if(a[mid]>=c){
r=mid;
}else{
l=mid;
}
}
u=l;
l=0,r=n+1;
while(r-l>1){
int mid=(l+r)/2;
if(a[mid]>c){
r=mid;
}else{
l=mid;
}
}
v=l;
printf("%lld\n",v-u);
}
}

ステータス

項目 データ
問題 0948 - Number-Collection
ユーザー名 ei2326
投稿日時 2024-05-27 22:39:39
言語 C++17
状態 Accepted
得点 10
ソースコード長 838 Byte
最大実行時間 317 ms
最大メモリ使用量 35940 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 20 ms 600 KB
1
2
3
4
input-sample2E__ AC 22 ms 568 KB
1
4
input01EEE AC 20 ms 412 KB
1
2
3
4
input02EEE AC 19 ms 512 KB
1
2
3
4
input03E__ AC 30 ms 484 KB
1
4
input04E__ AC 23 ms 452 KB
1
4
input05E__ AC 23 ms 548 KB
1
4
input06_E_ AC 146 ms 6148 KB
2
4
input07_E_ AC 176 ms 14564 KB
2
4
input08_E_ AC 245 ms 20768 KB
2
4
input09__E AC 317 ms 24564 KB
3
4
input10__E AC 162 ms 11368 KB
3
4
input11__E AC 223 ms 27984 KB
3
4
input12___ AC 115 ms 10104 KB
4
input13___ AC 129 ms 12948 KB
4
input14___ AC 96 ms 16352 KB
4
input15___ AC 265 ms 32292 KB
4
input16___ AC 263 ms 34820 KB
4
input17___ AC 253 ms 35940 KB
4
input18 AC 42 ms 12472 KB
4