Submission #32115

#TimeUsernameProblemLanguageResultExecution timeMemory
32115dongwon0427스트랩 (JOI14_straps)C++98
0 / 100
23 ms17892 KiB
#include <bits/stdc++.h> using namespace std; #define INF 2000000001 int n; int dp[2005][2005]; struct _tuple { int dan,val; }; _tuple A[2005]; 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; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...