Submission #799553

# Submission time Handle Problem Language Result Execution time Memory
799553 2023-07-31T15:57:04 Z vjudge1 Potatoes and fertilizers (LMIO19_bulves) C++17
24 / 100
298 ms 14816 KB
#include <iostream>
using namespace std;
long long int a[500005], b[500005];
int main() {
    long long int n, c = 0, d = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        c += a[i];
        d += b[i];
    }
    if (c == d) {
        long long int res = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] > b[i]) {
                res += a[i] - b[i];
                a[i + 1] += a[i] - b[i];
            }
            else if (a[i] < b[i]) {
                a[i + 1] -= b[i] - a[i];
                res += b[i] - a[i];
                a[i] = b[i];
            }
        }
        cout << res;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 15 ms 1288 KB Output is correct
5 Correct 31 ms 2496 KB Output is correct
6 Correct 110 ms 7512 KB Output is correct
7 Correct 298 ms 14816 KB Output is correct
8 Correct 198 ms 12924 KB Output is correct
9 Correct 162 ms 12232 KB Output is correct
10 Correct 112 ms 10024 KB Output is correct
11 Correct 117 ms 10052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 15 ms 1288 KB Output is correct
5 Correct 31 ms 2496 KB Output is correct
6 Correct 110 ms 7512 KB Output is correct
7 Correct 298 ms 14816 KB Output is correct
8 Correct 198 ms 12924 KB Output is correct
9 Correct 162 ms 12232 KB Output is correct
10 Correct 112 ms 10024 KB Output is correct
11 Correct 117 ms 10052 KB Output is correct
12 Incorrect 61 ms 4016 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -