답안 #5989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5989 2014-06-11T15:15:52 Z model_code 스트랩 (JOI14_straps) C++
100 / 100
48 ms 32672 KB
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 2010;

int N, A[MAXN], B[MAXN], dp[MAXN][2*MAXN+1];

int main()
{
	scanf("%d", &N);
	for(int i=0;i<N;i++) scanf("%d%d", A+i, B+i);

	for(int i=0;i<=2*MAXN;i++) dp[0][i] = -2100000000;
	dp[0][MAXN+1] = 0;

	for(int i=0;i<N;i++){
		for(int j=0;j<=2*MAXN;j++) dp[i+1][j] = -2100000000;

		for(int j=0;j<=2*MAXN;j++){
			int j2 = j + (A[i] - 1);
			if(j2 < 0) continue;
			if(j2 > 2*MAXN) j2 = 2*MAXN;

			dp[i+1][j2] = max(dp[i+1][j2], dp[i][j] + B[i]);
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
	}

	int ret = 0;
	for(int i=MAXN;i<=2*MAXN;i++) ret = max(ret, dp[N][i]);

	printf("%d\n", ret);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 32672 KB Output is correct
2 Correct 0 ms 32672 KB Output is correct
3 Correct 0 ms 32672 KB Output is correct
4 Correct 0 ms 32672 KB Output is correct
5 Correct 0 ms 32672 KB Output is correct
6 Correct 0 ms 32672 KB Output is correct
7 Correct 0 ms 32672 KB Output is correct
8 Correct 0 ms 32672 KB Output is correct
9 Correct 0 ms 32672 KB Output is correct
10 Correct 0 ms 32672 KB Output is correct
11 Correct 0 ms 32672 KB Output is correct
12 Correct 0 ms 32672 KB Output is correct
13 Correct 0 ms 32672 KB Output is correct
14 Correct 0 ms 32672 KB Output is correct
15 Correct 0 ms 32672 KB Output is correct
16 Correct 0 ms 32672 KB Output is correct
17 Correct 0 ms 32672 KB Output is correct
18 Correct 0 ms 32672 KB Output is correct
19 Correct 0 ms 32672 KB Output is correct
20 Correct 0 ms 32672 KB Output is correct
21 Correct 0 ms 32672 KB Output is correct
22 Correct 0 ms 32672 KB Output is correct
23 Correct 0 ms 32672 KB Output is correct
24 Correct 0 ms 32672 KB Output is correct
25 Correct 0 ms 32672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 32672 KB Output is correct
2 Correct 0 ms 32672 KB Output is correct
3 Correct 0 ms 32672 KB Output is correct
4 Correct 0 ms 32672 KB Output is correct
5 Correct 0 ms 32672 KB Output is correct
6 Correct 0 ms 32672 KB Output is correct
7 Correct 0 ms 32672 KB Output is correct
8 Correct 20 ms 32672 KB Output is correct
9 Correct 16 ms 32672 KB Output is correct
10 Correct 12 ms 32672 KB Output is correct
11 Correct 12 ms 32672 KB Output is correct
12 Correct 28 ms 32672 KB Output is correct
13 Correct 32 ms 32672 KB Output is correct
14 Correct 32 ms 32672 KB Output is correct
15 Correct 36 ms 32672 KB Output is correct
16 Correct 32 ms 32672 KB Output is correct
17 Correct 36 ms 32672 KB Output is correct
18 Correct 24 ms 32672 KB Output is correct
19 Correct 36 ms 32672 KB Output is correct
20 Correct 28 ms 32672 KB Output is correct
21 Correct 32 ms 32672 KB Output is correct
22 Correct 36 ms 32672 KB Output is correct
23 Correct 20 ms 32672 KB Output is correct
24 Correct 40 ms 32672 KB Output is correct
25 Correct 36 ms 32672 KB Output is correct
26 Correct 40 ms 32672 KB Output is correct
27 Correct 44 ms 32672 KB Output is correct
28 Correct 32 ms 32672 KB Output is correct
29 Correct 40 ms 32672 KB Output is correct
30 Correct 32 ms 32672 KB Output is correct
31 Correct 36 ms 32672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 32672 KB Output is correct
2 Correct 0 ms 32672 KB Output is correct
3 Correct 0 ms 32672 KB Output is correct
4 Correct 0 ms 32672 KB Output is correct
5 Correct 0 ms 32672 KB Output is correct
6 Correct 0 ms 32672 KB Output is correct
7 Correct 0 ms 32672 KB Output is correct
8 Correct 0 ms 32672 KB Output is correct
9 Correct 20 ms 32672 KB Output is correct
10 Correct 20 ms 32672 KB Output is correct
11 Correct 16 ms 32672 KB Output is correct
12 Correct 16 ms 32672 KB Output is correct
13 Correct 24 ms 32672 KB Output is correct
14 Correct 20 ms 32672 KB Output is correct
15 Correct 20 ms 32672 KB Output is correct
16 Correct 24 ms 32672 KB Output is correct
17 Correct 32 ms 32672 KB Output is correct
18 Correct 40 ms 32672 KB Output is correct
19 Correct 40 ms 32672 KB Output is correct
20 Correct 28 ms 32672 KB Output is correct
21 Correct 44 ms 32672 KB Output is correct
22 Correct 40 ms 32672 KB Output is correct
23 Correct 36 ms 32672 KB Output is correct
24 Correct 48 ms 32672 KB Output is correct
25 Correct 28 ms 32672 KB Output is correct
26 Correct 28 ms 32672 KB Output is correct
27 Correct 40 ms 32672 KB Output is correct
28 Correct 32 ms 32672 KB Output is correct
29 Correct 36 ms 32672 KB Output is correct
30 Correct 40 ms 32672 KB Output is correct
31 Correct 36 ms 32672 KB Output is correct
32 Correct 40 ms 32672 KB Output is correct
33 Correct 28 ms 32672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 32672 KB Output is correct
2 Correct 32 ms 32672 KB Output is correct
3 Correct 32 ms 32672 KB Output is correct
4 Correct 28 ms 32672 KB Output is correct
5 Correct 40 ms 32672 KB Output is correct
6 Correct 36 ms 32672 KB Output is correct
7 Correct 32 ms 32672 KB Output is correct
8 Correct 32 ms 32672 KB Output is correct
9 Correct 36 ms 32672 KB Output is correct
10 Correct 32 ms 32672 KB Output is correct
11 Correct 44 ms 32672 KB Output is correct
12 Correct 32 ms 32672 KB Output is correct
13 Correct 40 ms 32672 KB Output is correct
14 Correct 36 ms 32672 KB Output is correct
15 Correct 40 ms 32672 KB Output is correct
16 Correct 28 ms 32672 KB Output is correct
17 Correct 20 ms 32672 KB Output is correct
18 Correct 40 ms 32672 KB Output is correct
19 Correct 36 ms 32672 KB Output is correct
20 Correct 40 ms 32672 KB Output is correct
21 Correct 36 ms 32672 KB Output is correct
22 Correct 40 ms 32672 KB Output is correct
23 Correct 32 ms 32672 KB Output is correct
24 Correct 40 ms 32672 KB Output is correct
25 Correct 28 ms 32672 KB Output is correct