80分求调

P1114 “非常男女”计划

```cpp #include<bits/stdc++.h> using namespace std; int l[200010],r[200010],sum1,sum0,ans,n; int main() { cin>>n; for (int i=1;i<=n;i++){ int x; cin>>x; sum1+=(x==1), sum0+=(x==0); int t=sum0-sum1+n; if (!l[t]&&t!=n) l[t]=i; else r[t]=i; } for (int i=0;i<=2*n;i++) ans=max(ans,r[i]-l[i]); cout<<ans<<endl; return 0; } ```
by liuzhuoran141516 @ 2024-07-21 19:53:22


试一下
by liuzhuoran141516 @ 2024-07-21 19:53:52


@[liuzhuoran141516](/user/1351155) 好眼熟
by wuyu6688 @ 2024-08-01 22:07:08


|