# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384118 | LucaDantas | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 1 ms | 364 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 <cstdio>
#include <queue>
std::priority_queue<long long> q;
long long d, ans = 0;
int main() {
int n; scanf("%d", &n);
for(int i = 0; i < n; i++) {
int a, b; scanf("%d %d", &a, &b);
d += a - b;
if(d < 0) ans += -d;
if(q.size() && d < q.top()) ans += q.top() - (d<0?0:d), q.pop();
q.push(d<0?0:d);
}
printf("%lld\n", ans);
}
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... |