Submission #39692

# Submission time Handle Problem Language Result Execution time Memory
39692 2018-01-17T10:43:58 Z 14kg 스트랩 (JOI14_straps) C++11
100 / 100
13 ms 1136 KB
#include <stdio.h>
#include <algorithm>
#define INF 2000000000
#define max2(x,y) (x>y?x:y)
#define min2(x,y) (x<y?x:y)

using namespace std;
int n, dp[2001];
pair<int, int> in[2001];

int main() {
	int x, y, w, out = 0;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) dp[i] = -INF;
	for (int i = 1; i <= n; i++) scanf("%d %d", &in[i].first, &in[i].second);
	sort(in + 1, in + n + 1);
	for (int k = n; k >= 1; k--) {
		x = in[k].first - 1, y = in[k].second;
		if (x < 0) {
			for (int i = 0; i < n; i++) dp[i] = max2(dp[i], dp[i + 1] + y);
		}
		else {
			for (int i = n; i >= 0; i--) {
				w = min2(n, i + x);
				dp[w] = max2(dp[w], dp[i] + y);
			}
		}
	}
	for (int i = 0; i <= n; i++) out = max2(out, dp[i]);
	printf("%d", out);
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
straps.cpp:15:74: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d %d", &in[i].first, &in[i].second);
                                                                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1136 KB Output is correct
2 Correct 0 ms 1136 KB Output is correct
3 Correct 0 ms 1136 KB Output is correct
4 Correct 0 ms 1136 KB Output is correct
5 Correct 0 ms 1136 KB Output is correct
6 Correct 0 ms 1136 KB Output is correct
7 Correct 0 ms 1136 KB Output is correct
8 Correct 0 ms 1136 KB Output is correct
9 Correct 0 ms 1136 KB Output is correct
10 Correct 0 ms 1136 KB Output is correct
11 Correct 0 ms 1136 KB Output is correct
12 Correct 0 ms 1136 KB Output is correct
13 Correct 0 ms 1136 KB Output is correct
14 Correct 0 ms 1136 KB Output is correct
15 Correct 0 ms 1136 KB Output is correct
16 Correct 0 ms 1136 KB Output is correct
17 Correct 0 ms 1136 KB Output is correct
18 Correct 0 ms 1136 KB Output is correct
19 Correct 0 ms 1136 KB Output is correct
20 Correct 0 ms 1136 KB Output is correct
21 Correct 0 ms 1136 KB Output is correct
22 Correct 0 ms 1136 KB Output is correct
23 Correct 0 ms 1136 KB Output is correct
24 Correct 0 ms 1136 KB Output is correct
25 Correct 0 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1136 KB Output is correct
2 Correct 0 ms 1136 KB Output is correct
3 Correct 0 ms 1136 KB Output is correct
4 Correct 0 ms 1136 KB Output is correct
5 Correct 0 ms 1136 KB Output is correct
6 Correct 0 ms 1136 KB Output is correct
7 Correct 0 ms 1136 KB Output is correct
8 Correct 3 ms 1136 KB Output is correct
9 Correct 0 ms 1136 KB Output is correct
10 Correct 0 ms 1136 KB Output is correct
11 Correct 0 ms 1136 KB Output is correct
12 Correct 3 ms 1136 KB Output is correct
13 Correct 3 ms 1136 KB Output is correct
14 Correct 3 ms 1136 KB Output is correct
15 Correct 3 ms 1136 KB Output is correct
16 Correct 3 ms 1136 KB Output is correct
17 Correct 6 ms 1136 KB Output is correct
18 Correct 3 ms 1136 KB Output is correct
19 Correct 3 ms 1136 KB Output is correct
20 Correct 3 ms 1136 KB Output is correct
21 Correct 3 ms 1136 KB Output is correct
22 Correct 3 ms 1136 KB Output is correct
23 Correct 3 ms 1136 KB Output is correct
24 Correct 3 ms 1136 KB Output is correct
25 Correct 3 ms 1136 KB Output is correct
26 Correct 3 ms 1136 KB Output is correct
27 Correct 3 ms 1136 KB Output is correct
28 Correct 3 ms 1136 KB Output is correct
29 Correct 9 ms 1136 KB Output is correct
30 Correct 9 ms 1136 KB Output is correct
31 Correct 9 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1136 KB Output is correct
2 Correct 0 ms 1136 KB Output is correct
3 Correct 0 ms 1136 KB Output is correct
4 Correct 0 ms 1136 KB Output is correct
5 Correct 0 ms 1136 KB Output is correct
6 Correct 0 ms 1136 KB Output is correct
7 Correct 0 ms 1136 KB Output is correct
8 Correct 0 ms 1136 KB Output is correct
9 Correct 0 ms 1136 KB Output is correct
10 Correct 0 ms 1136 KB Output is correct
11 Correct 0 ms 1136 KB Output is correct
12 Correct 0 ms 1136 KB Output is correct
13 Correct 3 ms 1136 KB Output is correct
14 Correct 3 ms 1136 KB Output is correct
15 Correct 0 ms 1136 KB Output is correct
16 Correct 0 ms 1136 KB Output is correct
17 Correct 6 ms 1136 KB Output is correct
18 Correct 6 ms 1136 KB Output is correct
19 Correct 3 ms 1136 KB Output is correct
20 Correct 3 ms 1136 KB Output is correct
21 Correct 3 ms 1136 KB Output is correct
22 Correct 6 ms 1136 KB Output is correct
23 Correct 3 ms 1136 KB Output is correct
24 Correct 6 ms 1136 KB Output is correct
25 Correct 3 ms 1136 KB Output is correct
26 Correct 3 ms 1136 KB Output is correct
27 Correct 3 ms 1136 KB Output is correct
28 Correct 3 ms 1136 KB Output is correct
29 Correct 3 ms 1136 KB Output is correct
30 Correct 3 ms 1136 KB Output is correct
31 Correct 3 ms 1136 KB Output is correct
32 Correct 3 ms 1136 KB Output is correct
33 Correct 6 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1136 KB Output is correct
2 Correct 3 ms 1136 KB Output is correct
3 Correct 3 ms 1136 KB Output is correct
4 Correct 3 ms 1136 KB Output is correct
5 Correct 3 ms 1136 KB Output is correct
6 Correct 3 ms 1136 KB Output is correct
7 Correct 3 ms 1136 KB Output is correct
8 Correct 3 ms 1136 KB Output is correct
9 Correct 6 ms 1136 KB Output is correct
10 Correct 3 ms 1136 KB Output is correct
11 Correct 6 ms 1136 KB Output is correct
12 Correct 6 ms 1136 KB Output is correct
13 Correct 6 ms 1136 KB Output is correct
14 Correct 3 ms 1136 KB Output is correct
15 Correct 6 ms 1136 KB Output is correct
16 Correct 3 ms 1136 KB Output is correct
17 Correct 6 ms 1136 KB Output is correct
18 Correct 6 ms 1136 KB Output is correct
19 Correct 9 ms 1136 KB Output is correct
20 Correct 9 ms 1136 KB Output is correct
21 Correct 13 ms 1136 KB Output is correct
22 Correct 13 ms 1136 KB Output is correct
23 Correct 13 ms 1136 KB Output is correct
24 Correct 13 ms 1136 KB Output is correct
25 Correct 6 ms 1136 KB Output is correct