| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 331352 | Nson | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 327 ms | 23920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
scanf("%d", &n);
multiset<ll> s;
ll m = 0, b = 0; // y = m * x + b
auto apply_prefix_min = [&]() {
while(!s.empty() and m > 0) {
m--;
b += *prev(s.end());
s.erase(prev(s.end()));
}
};
ll d = 0;
for(int i = 0; i < n; i++) {
int aa, bb;
scanf("%d %d", &aa, &bb);
aa -= bb;
d += aa;
apply_prefix_min();
if(d >= 0) {
s.insert(d);
s.insert(d);
b -= d;
m += 1;
}
else {
m += 1;
b -= d;
}
}
while(!s.empty() and *prev(s.end()) > d) {
m--;
b += *prev(s.end());
s.erase(prev(s.end()));
}
printf("%lld\n", d * m + b);
}
컴파일 시 표준 에러 (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... | ||||
