# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384122 | 2021-03-31T13:52:26 Z | LucaDantas | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 1 ms | 364 KB |
#include <cstdio> #include <queue> std::priority_queue<long long> q; int main() { long long d, ans = 0; 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); q.push(d<0?0:d); } printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |