-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarrot_Chopdown.cpp
More file actions
44 lines (37 loc) · 812 Bytes
/
Copy pathCarrot_Chopdown.cpp
File metadata and controls
44 lines (37 loc) · 812 Bytes
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
42
43
44
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int cnt[N];
int zz[N];
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
for (int i = 0; i <= m + 2; i++) {
cnt[i] = 0;
zz[i] = 0;
}
for (int i = 0; i < n; i++) {
int curr;
cin >> curr;
cnt[curr]++;
}
for (int i = m; i >= 1; i--) {
zz[i] = zz[i + 1] + cnt[i];
}
int ans = 0;
for (int i = 1; i <= m;i++) {
int cur = zz[i];
if (2 * i <= m) {
cur += cnt[2 * i];
}
ans = max(ans, cur);
}
cout << ans << "\n";
}
return 0;
}