Submission #8240

#TimeUsernameProblemLanguageResultExecution timeMemory
8240dohyun0324스트랩 (JOI14_straps)C++98
0 / 100
8 ms16884 KiB
#include<stdio.h> #include<algorithm> using namespace std; int dap,n,a[2010],b[2010],d[2010][2010]; int main() { int i,j; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d %d",&a[i],&b[i]); } for(i=0;i<=n;i++) { for(j=2;j<=2000;j++) { d[i][j]=-2147483647; } } for(i=1;i<=n;i++) { for(j=0;j<=2000;j++) { if(d[i-1][j]!=-2147483647) { d[i][min(2000,j+a[i]-1)]=max(d[i][min(2000,j+a[i]-1)],d[i-1][j]+b[i]); d[i][j]=max(d[i][j],d[i-1][j]); } } } for(i=0;i<=2000;i++) { if(dap<d[n][i]) dap=d[n][i]; } printf("%d",dap); 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...