Submission #166843

#TimeUsernameProblemLanguageResultExecution timeMemory
166843anubhavdharNizin (COCI16_nizin)C++14
100 / 100
81 ms10232 KiB
#include<bits/stdc++.h> #define ll long long int #define FOR(i,N) for(i=0;i<N;i++) #define FORe(i,N) for(i=1;i<=N;i++) #define FORr(i,a,b) for(i=a;i<b;i++) #define ff first #define ss second #define mp make_pair #define pb push_back #define vi vector<ll> #define ii pair<ll,ll> #define vii vector<ii> const ll MAXN = 1e5; const ll LOGN = 17; const ll ROOTN = 320; const ll INF = 1e17+21; const ll MOD = 1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll N,i,a = 0,b = 0,c,d,l = 0,r = 0,ctr = 1; cin>>N; ll A[N]; c = d = N-1; FOR(i,N) cin>>A[i]; l = A[0]; r = A[N-1]; while(b < c) { //cout<<"entering for at ("<<a<<","<<b<<") and ("<<c<<","<<d<<")\n"; if (l == r) { //cout<<"found palindrome at ("<<a<<","<<b<<") and ("<<c<<","<<d<<")\n"; ctr += 2; if(b == c - 1) ctr--; b++; c--; a = b; d = c; l = A[b]; r = A[c]; } else if (l > r) { //cout<<"l>r\n"; c--; r += A[c]; } else { //cout<<"l<r\n"; b++; l += A[b]; } //cout<<"finally l = "<<l<<" and r = "<<r<<endl; } cout<<N - ctr; return 0; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:28:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
  ll N,i,a = 0,b = 0,c,d,l = 0,r = 0,ctr = 1;
         ^
#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...