| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1346791 | Jawad_Akbar_JJ | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 185 ms | 4648 KiB |
#include <iostream>
#include <queue>
using namespace std;
int main(){
long long n, Min = 0, p = 0;
cin>>n;
priority_queue<long long> A;
for (int i=1, a, b;i<=n;i++){
cin>>a>>b;
p += a - b;
if (p < 0)
Min += -p;
long long P = max(0LL, p);
if (i == n){
while (A.size() > 0 and A.top() > p)
Min += A.top() - p, A.pop();
}
else if (A.size() == 0)
A.push(P);
else if (P < A.top()){
Min += A.top() - P;
A.pop(), A.push(P), A.push(P);
}
else
A.push(P);
}
cout<<Min<<'\n';
}| # | 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... | ||||
