Submission #912746

# Submission time Handle Problem Language Result Execution time Memory
912746 2024-01-19T19:50:14 Z Neos Nizin (COCI16_nizin) C++14
100 / 100
51 ms 6276 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 7;

int n, a[N];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int cnt = 0;
    for (int l = 1, r = n; l < r; ) {
        if (a[l] == a[r]) {
            l++;
            r--;
            // (l + 1, r - 1)
        }
        else {
            if (a[l] > a[r]) {
                a[r - 1] += a[r];
                r--;
                //(l, r - 1)
            }
            else {
                a[l + 1] += a[l];
                l++;
                // (l + 1, r)
            }
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2652 KB Output is correct
2 Correct 5 ms 2648 KB Output is correct
3 Correct 5 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3420 KB Output is correct
2 Correct 20 ms 3576 KB Output is correct
3 Correct 22 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4956 KB Output is correct
2 Correct 35 ms 5088 KB Output is correct
3 Correct 40 ms 5624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 6100 KB Output is correct
2 Correct 51 ms 6276 KB Output is correct
3 Correct 45 ms 6228 KB Output is correct