899a
题意:给出一个序列,要么选出3个1的组合,要么选出一个2和一个1的组合,问最多能选出多少个组合
思路:贪心即可
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n, a[200010];
int x, y;
int main(){
cin>>n;
for(int i = 1; i<=n; i++){
cin>>a[i];
if(a[i] == 1) x++;
if(a[i] == 2) y++;
}
if(x == y){
cout<<x<<endl;
}
else if(x == 0){
cout<<0<<endl;
}
else if(y == 0 && x<3){
cout<<0<<endl;
}
else if(x>y){
int sum = y;
x-=y;
sum+=x/3;
cout<<sum<<endl;
}
else if(y>x){
cout<<x<<endl;
}
return 0;
}