# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623564 | ipaljak | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 140 ms | 15224 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const int MAXN = 5e5 + 10;
int n;
llint sum;
llint a[MAXN];
int main(void) {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int x, y;
scanf("%d%d", &x, &y);
if (i > 0) a[i] = a[i - 1];
a[i] += (llint)(x - y);
}
llint sol = 0;
for (int i = 0; i < n; ++i) {
if (a[i] < 0) {
sol += -a[i];
a[i] = 0;
}
if (a[i] > a[n - 1]) {
sol += a[i] - a[n - 1];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |