답안 #32116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
32116 2017-09-26T08:30:29 Z dongwon0427 스트랩 (JOI14_straps) C++
100 / 100
23 ms 17892 KB
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000001
int n;
int dp[2005][2005];
struct _tuple {
    int dan,val;
};
_tuple A[2005];
bool sf(_tuple a,_tuple b){
    return a.dan>b.dan;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>A[i].dan>>A[i].val;
    sort(A+1,A+1+n,sf);
    for(int i=0;i<=n;i++) {
        for(int j=0;j<=2000;j++) {
            dp[i][j]=-INF;
        }
    }
    dp[0][1]=0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=2000;j++) {
            dp[i][j]=dp[i-1][j];
        }
        for(int j=1;j<=2000;j++) {
            dp[i][min(j-1+A[i].dan,2000)] = max(dp[i][min(j-1+A[i].dan,2000)] , dp[i-1][j] + A[i].val);
        }
    }
    int ans=0;
    for(int i=0;i<=2000;i++) {
        ans=max(ans,dp[n][i]);
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17892 KB Output is correct
2 Correct 0 ms 17892 KB Output is correct
3 Correct 0 ms 17892 KB Output is correct
4 Correct 0 ms 17892 KB Output is correct
5 Correct 0 ms 17892 KB Output is correct
6 Correct 0 ms 17892 KB Output is correct
7 Correct 0 ms 17892 KB Output is correct
8 Correct 0 ms 17892 KB Output is correct
9 Correct 0 ms 17892 KB Output is correct
10 Correct 0 ms 17892 KB Output is correct
11 Correct 0 ms 17892 KB Output is correct
12 Correct 0 ms 17892 KB Output is correct
13 Correct 0 ms 17892 KB Output is correct
14 Correct 0 ms 17892 KB Output is correct
15 Correct 0 ms 17892 KB Output is correct
16 Correct 0 ms 17892 KB Output is correct
17 Correct 0 ms 17892 KB Output is correct
18 Correct 0 ms 17892 KB Output is correct
19 Correct 0 ms 17892 KB Output is correct
20 Correct 0 ms 17892 KB Output is correct
21 Correct 0 ms 17892 KB Output is correct
22 Correct 0 ms 17892 KB Output is correct
23 Correct 0 ms 17892 KB Output is correct
24 Correct 0 ms 17892 KB Output is correct
25 Correct 0 ms 17892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17892 KB Output is correct
2 Correct 0 ms 17892 KB Output is correct
3 Correct 0 ms 17892 KB Output is correct
4 Correct 0 ms 17892 KB Output is correct
5 Correct 0 ms 17892 KB Output is correct
6 Correct 0 ms 17892 KB Output is correct
7 Correct 0 ms 17892 KB Output is correct
8 Correct 6 ms 17892 KB Output is correct
9 Correct 6 ms 17892 KB Output is correct
10 Correct 9 ms 17892 KB Output is correct
11 Correct 13 ms 17892 KB Output is correct
12 Correct 16 ms 17892 KB Output is correct
13 Correct 9 ms 17892 KB Output is correct
14 Correct 23 ms 17892 KB Output is correct
15 Correct 16 ms 17892 KB Output is correct
16 Correct 13 ms 17892 KB Output is correct
17 Correct 13 ms 17892 KB Output is correct
18 Correct 16 ms 17892 KB Output is correct
19 Correct 16 ms 17892 KB Output is correct
20 Correct 13 ms 17892 KB Output is correct
21 Correct 19 ms 17892 KB Output is correct
22 Correct 19 ms 17892 KB Output is correct
23 Correct 16 ms 17892 KB Output is correct
24 Correct 13 ms 17892 KB Output is correct
25 Correct 19 ms 17892 KB Output is correct
26 Correct 16 ms 17892 KB Output is correct
27 Correct 23 ms 17892 KB Output is correct
28 Correct 13 ms 17892 KB Output is correct
29 Correct 16 ms 17892 KB Output is correct
30 Correct 16 ms 17892 KB Output is correct
31 Correct 19 ms 17892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17892 KB Output is correct
2 Correct 0 ms 17892 KB Output is correct
3 Correct 0 ms 17892 KB Output is correct
4 Correct 0 ms 17892 KB Output is correct
5 Correct 0 ms 17892 KB Output is correct
6 Correct 0 ms 17892 KB Output is correct
7 Correct 0 ms 17892 KB Output is correct
8 Correct 0 ms 17892 KB Output is correct
9 Correct 6 ms 17892 KB Output is correct
10 Correct 3 ms 17892 KB Output is correct
11 Correct 6 ms 17892 KB Output is correct
12 Correct 9 ms 17892 KB Output is correct
13 Correct 3 ms 17892 KB Output is correct
14 Correct 6 ms 17892 KB Output is correct
15 Correct 9 ms 17892 KB Output is correct
16 Correct 3 ms 17892 KB Output is correct
17 Correct 13 ms 17892 KB Output is correct
18 Correct 16 ms 17892 KB Output is correct
19 Correct 13 ms 17892 KB Output is correct
20 Correct 16 ms 17892 KB Output is correct
21 Correct 19 ms 17892 KB Output is correct
22 Correct 13 ms 17892 KB Output is correct
23 Correct 16 ms 17892 KB Output is correct
24 Correct 13 ms 17892 KB Output is correct
25 Correct 13 ms 17892 KB Output is correct
26 Correct 19 ms 17892 KB Output is correct
27 Correct 13 ms 17892 KB Output is correct
28 Correct 16 ms 17892 KB Output is correct
29 Correct 13 ms 17892 KB Output is correct
30 Correct 13 ms 17892 KB Output is correct
31 Correct 16 ms 17892 KB Output is correct
32 Correct 9 ms 17892 KB Output is correct
33 Correct 13 ms 17892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 17892 KB Output is correct
2 Correct 13 ms 17892 KB Output is correct
3 Correct 23 ms 17892 KB Output is correct
4 Correct 23 ms 17892 KB Output is correct
5 Correct 13 ms 17892 KB Output is correct
6 Correct 16 ms 17892 KB Output is correct
7 Correct 9 ms 17892 KB Output is correct
8 Correct 13 ms 17892 KB Output is correct
9 Correct 16 ms 17892 KB Output is correct
10 Correct 16 ms 17892 KB Output is correct
11 Correct 13 ms 17892 KB Output is correct
12 Correct 19 ms 17892 KB Output is correct
13 Correct 13 ms 17892 KB Output is correct
14 Correct 16 ms 17892 KB Output is correct
15 Correct 16 ms 17892 KB Output is correct
16 Correct 13 ms 17892 KB Output is correct
17 Correct 13 ms 17892 KB Output is correct
18 Correct 13 ms 17892 KB Output is correct
19 Correct 13 ms 17892 KB Output is correct
20 Correct 23 ms 17892 KB Output is correct
21 Correct 13 ms 17892 KB Output is correct
22 Correct 16 ms 17892 KB Output is correct
23 Correct 19 ms 17892 KB Output is correct
24 Correct 13 ms 17892 KB Output is correct
25 Correct 13 ms 17892 KB Output is correct