Submission #510279

# Submission time Handle Problem Language Result Execution time Memory
510279 2022-01-14T22:02:09 Z salamhassan Nizin (COCI16_nizin) C++14
100 / 100
166 ms 10148 KB
#include <bits/stdc++.h>
using namespace std;
long long a[1000007],n,l,r,ans;
int main()
{
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    l=0;
    r=n-1;
    while (l<=r)
    {
        if (a[l]==a[r])
        {
        l++;
        r--;
        }
        while (r>=l && a[l]!=a[r])
        {
        if (a[l]>a[r])
        {
            a[r-1]+=a[r];
            r--;
            n--;
            ans++;
        }
        else
        {
        a[l+1]+=a[l];
        l++;
        ans++;
        }

        }

    }

    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 844 KB Output is correct
2 Correct 16 ms 1196 KB Output is correct
3 Correct 14 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 2880 KB Output is correct
2 Correct 55 ms 4420 KB Output is correct
3 Correct 72 ms 5180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 6196 KB Output is correct
2 Correct 104 ms 8168 KB Output is correct
3 Correct 127 ms 9128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 135 ms 7992 KB Output is correct
2 Correct 140 ms 10072 KB Output is correct
3 Correct 166 ms 10148 KB Output is correct