-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Table_with_Numbers.cpp
More file actions
58 lines (48 loc) · 918 Bytes
/
Copy pathA_Table_with_Numbers.cpp
File metadata and controls
58 lines (48 loc) · 918 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) (v).begin(), (v).end()
void solve() {
int n,h,l;
cin>>n>>h>>l;
vector<int> v(n);
for(auto &x : v) cin>>x;
vector<bool> idx(n,false);
sort(all(v));
int k = n/2;
int cnth=0;
int cntl=0;
int both = 0;
for(int i=0;i<n;i++){
if(v[i]<=h && v[i]<=l){
both++;
}
else if(v[i]<=h){
cnth++;
}
else if(v[i]<=l){
cntl++;
}
}
int ans = 0;
ans+=min(cnth,cntl);
cnth-=ans;
cntl-=ans;
int extra = max(cnth,cntl);
int take = min(both,extra);
ans+=take;
both-=take;
ans+=both/2;
cout<<ans<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
// Successfully Submitted