# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1166859 | tamyte | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 98 ms | 14436 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
vector<int> a, b;
a = vector<int>(n);
b = vector<int>(n);
ll res = 0;
vector<ll> d;
ll now = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
now += a[i] - b[i];
d.push_back(now);
}
priority_queue<ll> pq;
for (int i = 0; i < n; ++i) {
if (d[i] < 0) {
res += -d[i];
d[i] = 0;
} else if (d[i] > now) {
res += d[i] - now;
d[i] = now;
}
pq.push(d[i]);
if (pq.top() > d[i]) {
# | 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... |