Submission #706571

# Submission time Handle Problem Language Result Execution time Memory
706571 2023-03-07T05:00:26 Z YugiHacker Nizin (COCI16_nizin) C++14
100 / 100
66 ms 10180 KB
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 1000006
using namespace std;
int n;
long long a[maxn];
main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    f1 (i, n) cin >> a[i];
    int l=1, r=n;
    int ans = 0;
    while (r > l)
    {
        if (a[l] == a[r])
        {
            l++, r--;
            continue;
        }
        if (a[l] < a[r]) a[l+1] += a[l], l++;
        else a[r-1] += a[r], r--;
        ans++;
    }
    cout << ans;
}

Compilation message

nizin.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 260 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 980 KB Output is correct
2 Correct 9 ms 1236 KB Output is correct
3 Correct 7 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3736 KB Output is correct
2 Correct 26 ms 4436 KB Output is correct
3 Correct 28 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 7716 KB Output is correct
2 Correct 48 ms 8160 KB Output is correct
3 Correct 55 ms 9168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 9900 KB Output is correct
2 Correct 57 ms 10160 KB Output is correct
3 Correct 54 ms 10180 KB Output is correct