Submission #510106

# Submission time Handle Problem Language Result Execution time Memory
510106 2022-01-14T17:34:46 Z MusSan07 Nizin (COCI16_nizin) C++17
100 / 100
63 ms 9620 KB
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll n,ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll l=0,r=n-1;
    while(l!=r){
        if(l==r-1&&a[l]==a[r]){
            break;
        }
        if(a[l]==a[r]){
            l++,r--;
        }
        else if(a[l]!=a[r]&&a[l]<a[r]){
            a[l+1]+=a[l];
            ans++,l++;
        }
        else {
            a[r-1]+=a[r];
            r--,ans++;
        }
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 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 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 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 312 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 6 ms 1056 KB Output is correct
2 Correct 6 ms 1228 KB Output is correct
3 Correct 6 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3652 KB Output is correct
2 Correct 27 ms 4364 KB Output is correct
3 Correct 35 ms 5208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 7340 KB Output is correct
2 Correct 47 ms 7724 KB Output is correct
3 Correct 55 ms 8480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 9620 KB Output is correct
2 Correct 58 ms 9264 KB Output is correct
3 Correct 61 ms 9272 KB Output is correct