# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
329076 | 2020-11-18T23:50:31 Z | Nirjhor | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 196 ms | 19272 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 500010; priority_queue <ll> pq; int n; ll a[N], b[N], steady; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%lld %lld", a + i, b + i); a[i] -= b[i], a[i] += a[i - 1]; } ll extra = 0; for (int i = 1; i <= n; ++i) { if (a[i] < 0) extra -= a[i], a[i] = 0; if (a[i] > a[n]) extra += a[i] - a[n], a[i] = a[n]; pq.emplace(a[i]); pq.emplace(a[i]); steady += pq.top() - a[i]; pq.pop(); } steady += extra; cout << steady << '\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 12 ms | 2152 KB | Output is correct |
5 | Correct | 25 ms | 3684 KB | Output is correct |
6 | Correct | 72 ms | 9824 KB | Output is correct |
7 | Correct | 150 ms | 19184 KB | Output is correct |
8 | Correct | 152 ms | 17244 KB | Output is correct |
9 | Correct | 146 ms | 16604 KB | Output is correct |
10 | Correct | 132 ms | 14296 KB | Output is correct |
11 | Correct | 129 ms | 14300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 12 ms | 2152 KB | Output is correct |
5 | Correct | 25 ms | 3684 KB | Output is correct |
6 | Correct | 72 ms | 9824 KB | Output is correct |
7 | Correct | 150 ms | 19184 KB | Output is correct |
8 | Correct | 152 ms | 17244 KB | Output is correct |
9 | Correct | 146 ms | 16604 KB | Output is correct |
10 | Correct | 132 ms | 14296 KB | Output is correct |
11 | Correct | 129 ms | 14300 KB | Output is correct |
12 | Correct | 39 ms | 5200 KB | Output is correct |
13 | Correct | 90 ms | 13276 KB | Output is correct |
14 | Correct | 150 ms | 19196 KB | Output is correct |
15 | Correct | 128 ms | 17296 KB | Output is correct |
16 | Correct | 127 ms | 16624 KB | Output is correct |
17 | Correct | 132 ms | 14428 KB | Output is correct |
18 | Correct | 1 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 2 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 2 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 2 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 2 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 2 ms | 492 KB | Output is correct |
18 | Correct | 1 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 2 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 12 ms | 2152 KB | Output is correct |
12 | Correct | 25 ms | 3684 KB | Output is correct |
13 | Correct | 72 ms | 9824 KB | Output is correct |
14 | Correct | 150 ms | 19184 KB | Output is correct |
15 | Correct | 152 ms | 17244 KB | Output is correct |
16 | Correct | 146 ms | 16604 KB | Output is correct |
17 | Correct | 132 ms | 14296 KB | Output is correct |
18 | Correct | 129 ms | 14300 KB | Output is correct |
19 | Correct | 39 ms | 5200 KB | Output is correct |
20 | Correct | 90 ms | 13276 KB | Output is correct |
21 | Correct | 150 ms | 19196 KB | Output is correct |
22 | Correct | 128 ms | 17296 KB | Output is correct |
23 | Correct | 127 ms | 16624 KB | Output is correct |
24 | Correct | 132 ms | 14428 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 492 KB | Output is correct |
27 | Correct | 2 ms | 492 KB | Output is correct |
28 | Correct | 2 ms | 492 KB | Output is correct |
29 | Correct | 1 ms | 492 KB | Output is correct |
30 | Correct | 1 ms | 492 KB | Output is correct |
31 | Correct | 2 ms | 492 KB | Output is correct |
32 | Correct | 45 ms | 5092 KB | Output is correct |
33 | Correct | 113 ms | 13376 KB | Output is correct |
34 | Correct | 196 ms | 19164 KB | Output is correct |
35 | Correct | 196 ms | 16732 KB | Output is correct |
36 | Correct | 150 ms | 17372 KB | Output is correct |
37 | Correct | 187 ms | 19272 KB | Output is correct |
38 | Correct | 144 ms | 15324 KB | Output is correct |
39 | Correct | 134 ms | 14556 KB | Output is correct |
40 | Correct | 137 ms | 14300 KB | Output is correct |
41 | Correct | 136 ms | 14300 KB | Output is correct |
42 | Correct | 136 ms | 14428 KB | Output is correct |
43 | Correct | 138 ms | 14300 KB | Output is correct |
44 | Correct | 152 ms | 19164 KB | Output is correct |
45 | Correct | 167 ms | 14684 KB | Output is correct |
46 | Correct | 121 ms | 13404 KB | Output is correct |
47 | Correct | 1 ms | 492 KB | Output is correct |