# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891420 | 2023-12-23T02:02:12 Z | ClHg2 | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> #define EVAL(x) #x " = " << (x) using std::cin; using std::cout; using i64 = int64_t; auto main() -> int { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); auto n = 0; cin >> n; auto sum = i64{0}, ans = i64{0}; auto heap = std::priority_queue<i64>{}; for (auto i = 0; i < n; ++i) { auto x = 0, y = 0; cin >> x >> y; sum += x - y, ans += std::abs(sum); heap.emplace(sum), heap.emplace(sum), heap.pop(); } for (auto i = 0; i < n; ++i) ans -= heap.top(), heap.pop(); cout << ans << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |