# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
623564 | ipaljak | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 140 ms | 15224 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const int MAXN = 5e5 + 10;
int n;
llint sum;
llint a[MAXN];
int main(void) {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int x, y;
scanf("%d%d", &x, &y);
if (i > 0) a[i] = a[i - 1];
a[i] += (llint)(x - y);
}
llint sol = 0;
for (int i = 0; i < n; ++i) {
if (a[i] < 0) {
sol += -a[i];
a[i] = 0;
}
if (a[i] > a[n - 1]) {
sol += a[i] - a[n - 1];
a[i] = a[n - 1];
}
}
priority_queue<llint> Q;
for (int i = 0; i < n; ++i) {
Q.push(a[i]);
if (Q.top() > a[i]) {
sol += Q.top() - a[i];
Q.pop();
Q.push(a[i]);
}
}
printf("%lld\n", sol);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |