TLE老师!
by NOI_AK_dreeeam @ 2022-09-30 14:12:46
~~TLE 老师好~~
by __Allen_123__ @ 2022-09-30 18:41:12
TLE老师,为什么我的ac代码这么短啊
```
#include<bits/stdc++.h>
using namespace std;
int n,a[100000+50],boy[100000+50],girl[100000+50],ans;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
scanf("%d",a+i);
for(int i=1;i<=n;i++)
{
boy[i]=boy[i-1]+(a[i]==1?1:0);
girl[i]=girl[i-1]+(a[i]==0?1:0);
}
for(int i=1;i<=n;i++)
for(int j=i+ans-1;j<=n;j++)//这里是重点,枚举剪枝
if(boy[j]-boy[i-1]==girl[j]-girl[i-1])
ans=max(ans,boy[j]-boy[i-1]+girl[j]-girl[i-1]);
cout<<ans;
return 0;
}
```
by dengyujie2020 @ 2022-09-30 19:53:17
@[NOI_AK_dreeeam](/user/686445) 他是你老师????
by register_new @ 2022-09-30 22:53:53