# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166843 | anubhavdhar | Nizin (COCI16_nizin) | C++14 | 81 ms | 10232 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |