답안 #783605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783605 2023-07-15T05:46:11 Z vjudge1 Potatoes and fertilizers (LMIO19_bulves) C++17
100 / 100
152 ms 15040 KB
#include<bits/stdc++.h>
using namespace std; 


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	int n;
    long long ans=0, pref=0, a, b;
    priority_queue <long long> pq;
    cin >> n;
	
	for(int i=0; i<n; i++){
        pq.push(0);
    }
	for (int i=0; i<n-1; i++){
        cin >> a >> b;
        pref+=(a-b);
        pq.push(pref);
        if(pref<pq.top()){
            ans+=pq.top()-pref;
            pq.pop();
            pq.push(pref);
        }
	}
	cin >> a >> b;
	pref+=(a-b);
	while(pq.size() && pref<pq.top()){
        ans+=pq.top()-pref;
        pq.pop();
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 12 ms 1492 KB Output is correct
5 Correct 25 ms 2512 KB Output is correct
6 Correct 81 ms 4556 KB Output is correct
7 Correct 108 ms 8656 KB Output is correct
8 Correct 126 ms 8648 KB Output is correct
9 Correct 108 ms 12384 KB Output is correct
10 Correct 79 ms 10172 KB Output is correct
11 Correct 86 ms 10144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 12 ms 1492 KB Output is correct
5 Correct 25 ms 2512 KB Output is correct
6 Correct 81 ms 4556 KB Output is correct
7 Correct 108 ms 8656 KB Output is correct
8 Correct 126 ms 8648 KB Output is correct
9 Correct 108 ms 12384 KB Output is correct
10 Correct 79 ms 10172 KB Output is correct
11 Correct 86 ms 10144 KB Output is correct
12 Correct 38 ms 3976 KB Output is correct
13 Correct 99 ms 11824 KB Output is correct
14 Correct 106 ms 15020 KB Output is correct
15 Correct 121 ms 13180 KB Output is correct
16 Correct 152 ms 12480 KB Output is correct
17 Correct 62 ms 10200 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 1 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 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 1 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 340 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 1 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 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 12 ms 1492 KB Output is correct
12 Correct 25 ms 2512 KB Output is correct
13 Correct 81 ms 4556 KB Output is correct
14 Correct 108 ms 8656 KB Output is correct
15 Correct 126 ms 8648 KB Output is correct
16 Correct 108 ms 12384 KB Output is correct
17 Correct 79 ms 10172 KB Output is correct
18 Correct 86 ms 10144 KB Output is correct
19 Correct 38 ms 3976 KB Output is correct
20 Correct 99 ms 11824 KB Output is correct
21 Correct 106 ms 15020 KB Output is correct
22 Correct 121 ms 13180 KB Output is correct
23 Correct 152 ms 12480 KB Output is correct
24 Correct 62 ms 10200 KB Output is correct
25 Correct 1 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 340 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 30 ms 4040 KB Output is correct
34 Correct 77 ms 11832 KB Output is correct
35 Correct 124 ms 14904 KB Output is correct
36 Correct 116 ms 12588 KB Output is correct
37 Correct 116 ms 13172 KB Output is correct
38 Correct 126 ms 15040 KB Output is correct
39 Correct 71 ms 11208 KB Output is correct
40 Correct 74 ms 10344 KB Output is correct
41 Correct 71 ms 10116 KB Output is correct
42 Correct 71 ms 10180 KB Output is correct
43 Correct 70 ms 10168 KB Output is correct
44 Correct 72 ms 10140 KB Output is correct
45 Correct 141 ms 15016 KB Output is correct
46 Correct 57 ms 10444 KB Output is correct
47 Correct 80 ms 9800 KB Output is correct