求助 WA两个点50分
查看原帖
求助 WA两个点50分
400468
Aakkosetsumussa楼主2022/9/12 13:55
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],v[100005],ans=1;
int os=0,l,r,o[100005];
int main() {
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		o[i]=o[i-1]+(a[i]==1);
		if(a[i]==1) os++;
		if(!l&&a[i]==2) l=i;
		if(a[i]==3) r=i;
	}
	ans=max(ans,os);
	//cout<<ans<<endl;
	//cout<<l<<" "<<r<<endl;
	if(o[l]==0) ans++;
	if(o[n]-o[r]==0) ans++;
	cout<<ans<<endl;
	return 0;
}
/*
6
3 1 3 2 1 2
*/
2022/9/12 13:55
加载中...