Submission #25608

# Submission time Handle Problem Language Result Execution time Memory
25608 2017-06-23T08:07:13 Z kdh9949 스트랩 (JOI14_straps) C++14
100 / 100
23 ms 17972 KB
#include <bits/stdc++.h>
using namespace std;

struct Str{
	int a, v;
	bool operator<(const Str &oth) const {
		return a > oth.a;
	}
};

const int inf = 1e9;
int n, dp[2020][2020];
Str a[2020];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].a, &a[i].v);
	sort(a + 1, a + n + 1);
	fill(dp[0], dp[0] + n + 1, -inf);
	dp[0][1] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++) dp[i][j] = dp[i - 1][j];
		for(int j = 1; j <= n; j++){
			int &ndp = dp[i][min(j + a[i].a - 1, n)];
			ndp = max(ndp, dp[i - 1][j] + a[i].v);
		}
	}
	printf("%d\n", *max_element(dp[n], dp[n] + n + 1));
}

Compilation message

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