Submission #71685


ソースコード

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
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define ll long long
#define ptn(v) next_permutation(v.begin(), v.end())
#define fixed(v) fixed << setprecision(v)
#define total(n) (n * (n + 1) / 2)
#define combi(n) (n * (n - 1) / 2) // n個の数の組み合わせ数
#define lcm(a, b) ((a) * (b) / __gcd(a, b))
// binery_search(all(v),key) = keyがあるかないかをboolで返す
// lower_bound(all(v),key) = key以上のイテレーターを返す(一番左)
// upper_bound(all(v),key) = keyより大きい要素のイテレーターを返す
// 最小値=max_element(v.begin(),v.end());
// 最大値=min_element(v.begin(),v.end());
#define mod ((long long)1000000007)
using namespace std;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//-----------------------------------------------------
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int q;
cin >> q;
vector<ll> v(q);
for (int i = 0; i < q; i++) {
cin >> v[i];
}
ll ans = 0;
for (int i = 0; i < q; i++) {
cout << (upper_bound(all(a), v[i]) - lower_bound(all(a), v[i])) << '\n';
}
return (0);
}

ステータス

項目 データ
問題 0948 - Number-Collection
ユーザー名 ei2134
投稿日時 2022-08-05 13:59:03
言語 C++17
状態 Accepted
得点 10
ソースコード長 1250 Byte
最大実行時間 285 ms
最大メモリ使用量 31948 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 29 ms 604 KB
1
2
3
4
input-sample2E__ AC 19 ms 560 KB
1
4
input01EEE AC 28 ms 644 KB
1
2
3
4
input02EEE AC 23 ms 588 KB
1
2
3
4
input03E__ AC 17 ms 536 KB
1
4
input04E__ AC 23 ms 600 KB
1
4
input05E__ AC 16 ms 664 KB
1
4
input06_E_ AC 121 ms 8788 KB
2
4
input07_E_ AC 143 ms 16576 KB
2
4
input08_E_ AC 184 ms 23284 KB
2
4
input09__E AC 285 ms 25284 KB
3
4
input10__E AC 166 ms 12184 KB
3
4
input11__E AC 209 ms 26636 KB
3
4
input12___ AC 102 ms 10160 KB
4
input13___ AC 137 ms 12944 KB
4
input14___ AC 97 ms 14812 KB
4
input15___ AC 241 ms 31100 KB
4
input16___ AC 243 ms 31524 KB
4
input17___ AC 230 ms 31948 KB
4
input18 AC 35 ms 8696 KB
4