Submission #510078

# Submission time Handle Problem Language Result Execution time Memory
510078 2022-01-14T16:28:54 Z Rasoul006 Nizin (COCI16_nizin) C++17
80 / 100
31 ms 9160 KB
#include <bits/stdc++.h>

#define endl "\n" ;

typedef long long ll ;

using namespace std;

ll a[555555];

ll n,l,r,ans;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n;

    for (int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }

    r = n-1;

    while (l<=r)
    {
        if (a[r]==a[l])
        {
            r--;
            l++;
        }
        else if (a[r]<a[l])
        {
            a[r-1]+=a[r];
            r--;
            ans++;
        }
        else if (a[l]<a[r])
        {
            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 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 1 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 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 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 844 KB Output is correct
2 Correct 5 ms 1084 KB Output is correct
3 Correct 6 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2904 KB Output is correct
2 Correct 23 ms 3672 KB Output is correct
3 Correct 27 ms 4292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 9140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 9160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -