-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1993B.cpp
More file actions
46 lines (43 loc) · 1.02 KB
/
1993B.cpp
File metadata and controls
46 lines (43 loc) · 1.02 KB
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
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
int t;cin>>t;
while (t--)
{
int n;cin>>n;
vector<int> arr(n);
int max=0;
ll maxodd=0;
int neven=0;
int nodd=0;
for(int i=0;i<n;i++) {
cin>>arr[i];
if(arr[i]>max) max=arr[i];
if(arr[i]%2==0) neven++;
else {
nodd++;
if(arr[i]>maxodd) maxodd=arr[i];
}
}
if((nodd==n) || (neven==n)) {
cout<<0<<endl;
}else if(max==maxodd) {
cout<<neven<<endl;
}else{
sort(arr.begin(),arr.end());
int op=neven;
for(int i=0;i<n;i++) {
if(arr[i]%2==0) {
if(arr[i]<maxodd) maxodd+= arr[i];
else {
op++;
break;
}
}
}
cout<<op<<endl;
}
}
return 0;
}