37 lines
663 B
C++
37 lines
663 B
C++
#include <iostream>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int n,a[100001],yi=0,er=0,ans=0;
|
|
cin>>n;
|
|
for(int i=1;i<=n;i++){
|
|
cin>>a[i];
|
|
if(a[i]==1){
|
|
yi++;
|
|
}
|
|
if(a[i]==2){
|
|
er++;
|
|
}
|
|
}
|
|
int per=0;
|
|
for(int i=1;i<=yi;i++){
|
|
if(a[i]!=1){
|
|
ans++;
|
|
if(a[i]==2){
|
|
per++;
|
|
}
|
|
}
|
|
}
|
|
for(int i=yi+1;i<=er+yi;i++){
|
|
if(a[i]!=2){
|
|
ans++;
|
|
if(a[i]==1&&per>0){
|
|
per--;
|
|
ans--;
|
|
}
|
|
}
|
|
}
|
|
cout<<ans;
|
|
return 0;
|
|
}
|