Submission #156450

# Submission time Handle Problem Language Result Execution time Memory
156450 2019-10-05T17:06:19 Z mdn2002 Nizin (COCI16_nizin) C++14
100 / 100
266 ms 8312 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long n,a[1000006];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    long long l=0,r=n-1,lsum=a[0],rsum=a[n-1],ans=0;
    while(l<r)
    {
        if(lsum<rsum)
        {
            l++;
            lsum+=a[l];
            ans++;
        }
        else if(lsum>rsum)
        {
            r--;
            rsum+=a[r];
            ans++;
        }
        else
        {
            lsum=a[l+1];
            rsum=a[r-1];
            l++;
            r--;
        }
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 888 KB Output is correct
2 Correct 28 ms 1016 KB Output is correct
3 Correct 29 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 3028 KB Output is correct
2 Correct 115 ms 3568 KB Output is correct
3 Correct 134 ms 4252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 6264 KB Output is correct
2 Correct 213 ms 6648 KB Output is correct
3 Correct 238 ms 7396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 7928 KB Output is correct
2 Correct 265 ms 8156 KB Output is correct
3 Correct 266 ms 8312 KB Output is correct