Submission #2140

#TimeUsernameProblemLanguageResultExecution timeMemory
2140hana5505앱 (KOI13_app)C++98
21 / 21
0 ms1128 KiB
#include<stdio.h> int memo[101]; int cost[101]; int d[10001]; int main() { int n,m,i,j,s=0; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) scanf("%d",&memo[i]); for(i=1;i<=n;i++) scanf("%d",&cost[i]); d[cost[1]]=memo[1]; s=cost[1]; d[0]=1; for(i=2;i<=n;i++){ for(j=s;j>=1;j--){ if(d[j] && d[j+cost[i]]<d[j]+memo[i]) d[j+cost[i]]=d[j]+memo[i]; } if(d[cost[i]]<memo[i]) d[cost[i]]=memo[i]; s+=cost[i]; if(s>10000) s=10000; } for(i=1;i<=10000;i++){ if(d[i]>=m) break; } printf("%d",i); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...