# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
587929 | 2022-07-02T14:19:19 Z | jmyszka2007 | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 212 ms | 15208 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; scanf("%d", &n); vector<int>a(n + 1); vector<int>b(n + 1); for(int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); } ll ans = 0; ll d = 0; priority_queue<ll>q; for(int i = 1; i <= n; i++) { d += a[i] - b[i]; ans += abs(d); if(d < 0) { q.push(0); q.push(0); } else { q.push(d); q.push(d); } q.pop(); } while(!q.empty()) { ll x = q.top(); q.pop(); ans -= min(x, d); } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 14 ms | 1336 KB | Output is correct |
5 | Correct | 31 ms | 2856 KB | Output is correct |
6 | Correct | 94 ms | 7748 KB | Output is correct |
7 | Correct | 136 ms | 15204 KB | Output is correct |
8 | Correct | 158 ms | 13280 KB | Output is correct |
9 | Correct | 134 ms | 12760 KB | Output is correct |
10 | Correct | 120 ms | 10300 KB | Output is correct |
11 | Correct | 126 ms | 10324 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 14 ms | 1336 KB | Output is correct |
5 | Correct | 31 ms | 2856 KB | Output is correct |
6 | Correct | 94 ms | 7748 KB | Output is correct |
7 | Correct | 136 ms | 15204 KB | Output is correct |
8 | Correct | 158 ms | 13280 KB | Output is correct |
9 | Correct | 134 ms | 12760 KB | Output is correct |
10 | Correct | 120 ms | 10300 KB | Output is correct |
11 | Correct | 126 ms | 10324 KB | Output is correct |
12 | Correct | 44 ms | 4012 KB | Output is correct |
13 | Correct | 114 ms | 10956 KB | Output is correct |
14 | Correct | 140 ms | 15196 KB | Output is correct |
15 | Correct | 163 ms | 13280 KB | Output is correct |
16 | Correct | 173 ms | 12636 KB | Output is correct |
17 | Correct | 119 ms | 10560 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 312 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 14 ms | 1336 KB | Output is correct |
12 | Correct | 31 ms | 2856 KB | Output is correct |
13 | Correct | 94 ms | 7748 KB | Output is correct |
14 | Correct | 136 ms | 15204 KB | Output is correct |
15 | Correct | 158 ms | 13280 KB | Output is correct |
16 | Correct | 134 ms | 12760 KB | Output is correct |
17 | Correct | 120 ms | 10300 KB | Output is correct |
18 | Correct | 126 ms | 10324 KB | Output is correct |
19 | Correct | 44 ms | 4012 KB | Output is correct |
20 | Correct | 114 ms | 10956 KB | Output is correct |
21 | Correct | 140 ms | 15196 KB | Output is correct |
22 | Correct | 163 ms | 13280 KB | Output is correct |
23 | Correct | 173 ms | 12636 KB | Output is correct |
24 | Correct | 119 ms | 10560 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 47 ms | 4112 KB | Output is correct |
34 | Correct | 115 ms | 10952 KB | Output is correct |
35 | Correct | 212 ms | 15160 KB | Output is correct |
36 | Correct | 186 ms | 12732 KB | Output is correct |
37 | Correct | 157 ms | 13236 KB | Output is correct |
38 | Correct | 191 ms | 15128 KB | Output is correct |
39 | Correct | 131 ms | 11288 KB | Output is correct |
40 | Correct | 141 ms | 10864 KB | Output is correct |
41 | Correct | 126 ms | 10460 KB | Output is correct |
42 | Correct | 124 ms | 10328 KB | Output is correct |
43 | Correct | 126 ms | 10328 KB | Output is correct |
44 | Correct | 142 ms | 10408 KB | Output is correct |
45 | Correct | 184 ms | 15208 KB | Output is correct |
46 | Correct | 144 ms | 10712 KB | Output is correct |
47 | Correct | 124 ms | 10232 KB | Output is correct |