| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363678 | vjudge1 | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 81 ms | 8556 KiB |
/*
address:https://vjudge.net/problem/OJUZ-LMIO19_bulves
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 5;
int n;
LL a[N];
LL ans;
priority_queue<LL>q;
int main() {
scanf("%d", &n);
for (int i = 1;i <= n;++i) {
int x, y;scanf("%d%d", &x, &y);
a[i] = a[i - 1] + x - y;
}
for (int i = 0;i <= n;++i) {
LL x = min(a[n], max(0ll, a[i]));
ans += abs(x - a[i]);
q.push(x);
if (x < q.top()) {
ans += q.top() - x;
q.push(x);
q.pop();
}
}
printf("%lld", ans);
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
