# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200104 | SamAnd | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 257 ms | 15332 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;
const int N = 500005;
int n;
long long a[N];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
{
scanf("%lld", &a[i]);
int x;
scanf("%d", &x);
a[i] -= x;
a[i] += a[i - 1];
}
long long ans = 0;
for (int i = 1; i <= n; ++i)
{
if (a[i] < 0)
{
ans += (-a[i]);
a[i] = 0;
}
if (a[i] > a[n])
{
ans += (a[i] - a[n]);
a[i] = a[n];
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... |