답안 #204673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204673 2020-02-26T15:20:36 Z nhho Potatoes and fertilizers (LMIO19_bulves) C++14
100 / 100
220 ms 15204 KB
#include <bits/stdc++.h>

using namespace std;

int n;
long long ans, x[500001];
priority_queue<long long> q;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int ta, tb;
		scanf("%d%d", &ta, &tb);
		x[i + 1] = x[i] + ta - tb;
	}
	for (int i = 1; i < n; i++) {
		if (x[i] < 0) {
			ans -= x[i];
			x[i] = 0;
		} else if (x[i] > x[n]) {
			ans += x[i] - x[n];
			x[i] = x[n];
		}
		q.push(x[i]);
		ans += q.top() - x[i];
		q.push(x[i]);
		q.pop();
	}
	printf("%lld\n", ans);
}

Compilation message

bulves.cpp: In function 'int main()':
bulves.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bulves.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &ta, &tb);
   ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 18 ms 1780 KB Output is correct
5 Correct 32 ms 2928 KB Output is correct
6 Correct 88 ms 7788 KB Output is correct
7 Correct 176 ms 15204 KB Output is correct
8 Correct 137 ms 13412 KB Output is correct
9 Correct 164 ms 12748 KB Output is correct
10 Correct 130 ms 10468 KB Output is correct
11 Correct 134 ms 10468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 18 ms 1780 KB Output is correct
5 Correct 32 ms 2928 KB Output is correct
6 Correct 88 ms 7788 KB Output is correct
7 Correct 176 ms 15204 KB Output is correct
8 Correct 137 ms 13412 KB Output is correct
9 Correct 164 ms 12748 KB Output is correct
10 Correct 130 ms 10468 KB Output is correct
11 Correct 134 ms 10468 KB Output is correct
12 Correct 49 ms 4228 KB Output is correct
13 Correct 115 ms 11108 KB Output is correct
14 Correct 181 ms 15204 KB Output is correct
15 Correct 139 ms 13412 KB Output is correct
16 Correct 161 ms 12644 KB Output is correct
17 Correct 140 ms 10468 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 18 ms 1780 KB Output is correct
12 Correct 32 ms 2928 KB Output is correct
13 Correct 88 ms 7788 KB Output is correct
14 Correct 176 ms 15204 KB Output is correct
15 Correct 137 ms 13412 KB Output is correct
16 Correct 164 ms 12748 KB Output is correct
17 Correct 130 ms 10468 KB Output is correct
18 Correct 134 ms 10468 KB Output is correct
19 Correct 49 ms 4228 KB Output is correct
20 Correct 115 ms 11108 KB Output is correct
21 Correct 181 ms 15204 KB Output is correct
22 Correct 139 ms 13412 KB Output is correct
23 Correct 161 ms 12644 KB Output is correct
24 Correct 140 ms 10468 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 56 ms 4208 KB Output is correct
33 Correct 130 ms 11032 KB Output is correct
34 Correct 220 ms 15204 KB Output is correct
35 Correct 197 ms 13120 KB Output is correct
36 Correct 156 ms 13412 KB Output is correct
37 Correct 211 ms 15204 KB Output is correct
38 Correct 142 ms 11364 KB Output is correct
39 Correct 148 ms 10980 KB Output is correct
40 Correct 143 ms 10472 KB Output is correct
41 Correct 141 ms 10440 KB Output is correct
42 Correct 148 ms 10468 KB Output is correct
43 Correct 149 ms 10468 KB Output is correct
44 Correct 192 ms 15204 KB Output is correct
45 Correct 165 ms 10956 KB Output is correct
46 Correct 137 ms 10340 KB Output is correct
47 Correct 6 ms 376 KB Output is correct