| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1135953 | MateiKing80 | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 219 ms | 12468 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int n;
cin >> n;
vector<ll> a(n), b(n);
for(int i = 0; i < n; i ++)
cin >> a[i] >> b[i];
ll c = 0;
for(int i = 0; i < n; i ++)
c += a[i] - b[i];
ll cost = 0;
priority_queue<ll> pq;
ll d = 0;
for(int i = 0; i < n; i ++)
{
d += a[i] - b[i];
ll e = d;
if(e < 0)
{
cost -= e;
e = 0;
}
else if(e > c)
{
cost += e - c;
e = c;
}
pq.push(e);
pq.push(e);
cost += pq.top() - e;
pq.pop();
}
cout << cost;
}
| # | 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... | ||||
