Submission #510296

#TimeUsernameProblemLanguageResultExecution timeMemory
510296Toqa44Nizin (COCI16_nizin)C++17
0 / 100
58 ms7856 KiB
#include <bits/stdc++.h> #define endl "\n" using namespace std ; typedef long long ll; typedef long double ld ; ll n,a[1000005],sum1,sum2,ans,z; map<ll,ll>mp; vector<ll>v; bool f; set<ll>ss; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for(int g=0;g<n;g++) cin>>a[g]; ll i=0; ll j=n-1;z=n; for(int c=0;c<=n/2;c++){ if(a[c]==a[(n-c)-1]) f=0; else{ f=1; break;}} if(f==0){ cout<<0<<endl; return 0;} sum1=a[0]; sum2=a[n-1]; while(j-i>1) { if(sum1==sum2) { j--; i++; sum1=a[i]; sum2=a[j]; } else if(sum1>sum2) { sum2+=a[j-1]; j--; ans++; z--; } else{ sum1+=a[i+1]; ans++; z--; i++;} } if(z%2==0) cout<<ans<<endl; else{ if(ans==0) cout<<0<<endl; else cout<<ans-1<<endl;} return 0 ; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:14:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |    for(int g=0;g<n;g++)
      |    ^~~
nizin.cpp:16:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |     ll i=0; ll j=n-1;z=n;
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...