# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471562 | 2021-09-09T22:48:35 Z | CaroLinda | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 189 ms | 15224 KB |
#include <bits/stdc++.h> #define debug #define ll long long const int MAXN = 5e5+10 ; using namespace std ; int N ; ll C[MAXN] , x , y ; ll ans , p ; priority_queue< ll > q ; int main() { scanf("%d", &N ) ; for(int i = 0 ; i < N ; i++ ) { scanf("%lld %lld", &x, &y ) ; C[i] = x-y ; if(i) C[i] += C[i-1] ; } for(int i = 0 ; i < N ; i++ ) { if(C[i] < 0 ) ans -= C[i] , C[i] = 0 ; if(C[i] > C[N-1] ) ans += C[i]-C[N-1] , C[i] = C[N-1] ; q.push(C[i]) ; q.push(C[i]) ; ans += abs(q.top()-C[i]) ; q.pop() ; } printf("%lld\n" , ans ) ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 17 ms | 1556 KB | Output is correct |
5 | Correct | 26 ms | 2788 KB | Output is correct |
6 | Correct | 75 ms | 7784 KB | Output is correct |
7 | Correct | 157 ms | 15092 KB | Output is correct |
8 | Correct | 137 ms | 13224 KB | Output is correct |
9 | Correct | 140 ms | 12652 KB | Output is correct |
10 | Correct | 130 ms | 10364 KB | Output is correct |
11 | Correct | 132 ms | 10280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 17 ms | 1556 KB | Output is correct |
5 | Correct | 26 ms | 2788 KB | Output is correct |
6 | Correct | 75 ms | 7784 KB | Output is correct |
7 | Correct | 157 ms | 15092 KB | Output is correct |
8 | Correct | 137 ms | 13224 KB | Output is correct |
9 | Correct | 140 ms | 12652 KB | Output is correct |
10 | Correct | 130 ms | 10364 KB | Output is correct |
11 | Correct | 132 ms | 10280 KB | Output is correct |
12 | Correct | 40 ms | 4040 KB | Output is correct |
13 | Correct | 94 ms | 10920 KB | Output is correct |
14 | Correct | 178 ms | 15112 KB | Output is correct |
15 | Correct | 137 ms | 13332 KB | Output is correct |
16 | Correct | 147 ms | 12608 KB | Output is correct |
17 | Correct | 175 ms | 10364 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 216 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 324 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 216 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 324 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 336 KB | Output is correct |
14 | Correct | 2 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 336 KB | Output is correct |
16 | Correct | 2 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 216 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 324 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 17 ms | 1556 KB | Output is correct |
12 | Correct | 26 ms | 2788 KB | Output is correct |
13 | Correct | 75 ms | 7784 KB | Output is correct |
14 | Correct | 157 ms | 15092 KB | Output is correct |
15 | Correct | 137 ms | 13224 KB | Output is correct |
16 | Correct | 140 ms | 12652 KB | Output is correct |
17 | Correct | 130 ms | 10364 KB | Output is correct |
18 | Correct | 132 ms | 10280 KB | Output is correct |
19 | Correct | 40 ms | 4040 KB | Output is correct |
20 | Correct | 94 ms | 10920 KB | Output is correct |
21 | Correct | 178 ms | 15112 KB | Output is correct |
22 | Correct | 137 ms | 13332 KB | Output is correct |
23 | Correct | 147 ms | 12608 KB | Output is correct |
24 | Correct | 175 ms | 10364 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 336 KB | Output is correct |
27 | Correct | 2 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 336 KB | Output is correct |
29 | Correct | 2 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 47 ms | 4020 KB | Output is correct |
34 | Correct | 113 ms | 10808 KB | Output is correct |
35 | Correct | 189 ms | 15224 KB | Output is correct |
36 | Correct | 182 ms | 12704 KB | Output is correct |
37 | Correct | 173 ms | 13292 KB | Output is correct |
38 | Correct | 181 ms | 15156 KB | Output is correct |
39 | Correct | 140 ms | 11304 KB | Output is correct |
40 | Correct | 142 ms | 10800 KB | Output is correct |
41 | Correct | 144 ms | 10300 KB | Output is correct |
42 | Correct | 148 ms | 10276 KB | Output is correct |
43 | Correct | 139 ms | 10268 KB | Output is correct |
44 | Correct | 140 ms | 10316 KB | Output is correct |
45 | Correct | 166 ms | 15144 KB | Output is correct |
46 | Correct | 164 ms | 10672 KB | Output is correct |
47 | Correct | 127 ms | 10212 KB | Output is correct |