RE是怎么回事啊!!!
查看原帖
RE是怎么回事啊!!!
175801
黑虎阿福楼主2020/8/12 01:45

求大佬为我指明为何RE

#include<iostream>
#include<cstring>
using namespace std;
int n,b,c[100001],s=0,m=0,x;//不是long long问题 
bool a[100001],d[100001];
int main(){
	cin>>n;
	x=n;
	memset(d,0,sizeof(d));
	for(b=1;b<=n;b++)
	cin>>a[b];
	d[0]=1;
	c[0]=0;
	for(b=1;b<=x;b++){
		if(a[b]==1)
		s++;
		else
		s--;
		if(d[s]==0){
			d[s]=1;
			c[s]=b;
		}
		else
		m=max(m,b-c[s]);
	}
	cout<<m;
	return 0;
}
2020/8/12 01:45
加载中...