c++本地编译能过,提交后CE

P1114 “非常男女”计划

撞库函数名了。
by _cyle_King @ 2022-10-04 19:58:37


`index`改成`idx`试试
by ssytxy2024 @ 2022-10-04 19:58:50


index 是万能头关键字 -----------------------改头文件罢 ------------ ```cpp #include <bits/stdc++.h> using namespace std; const int maxn=1e6 + 10; int a[maxn],sum[maxn],qwq[2 * maxn]; int main() { int n; scanf("%d",&n); sum[0]=0; memset(qwq,-1,sizeof(qwq)); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); if (a[i] == 0) a[i] = -1; sum[i] = sum[i - 1] + a[i]; int x = sum[i] + 1e6; if (qwq[x] == -1) qwq[x] = i; } int ans=0; for(int i=2;i<=n;++i) { int x=sum[i]+1e6; ans=max(ans,i-qwq[x]); } cout<<ans; return 0; } ```
by Sir_en @ 2022-10-04 20:01:10


@[Sir_en](/user/665463) 改数组或头文件
by Sir_en @ 2022-10-04 20:04:59


|