| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357545 | duyanhchupapi | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 163 ms | 8788 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
priority_queue <ll> pq;
ll res = 0, d = 0;
while (n--) {
ll a, b;
cin >> a >> b;
d += a - b;
pq.push(d);
pq.push(d);
pq.push(0);
res += max(0LL, pq.top() - d);
pq.pop();
}
while (!pq.empty()) res += max(0LL, pq.top() - d), pq.pop();
cout << res;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
