Submission #5356

#TimeUsernameProblemLanguageResultExecution timeMemory
5356baneling100앱 (KOI13_app)C++98
21 / 21
0 ms1128 KiB
#include <stdio.h> int N, M, m[101], c[101], d[10001], ans; void input(void) { int i, sum=0; scanf("%d %d",&N,&M); for(i=1 ; i<=N ; i++) scanf("%d",&m[i]); for(i=1 ; i<=N ; i++) { scanf("%d",&c[i]); sum+=c[i]; } for(i=1 ; i<=sum ; i++) d[i]=-1; } void process(void) { int i, j, limit=0; for(i=1 ; i<=N ; i++) { limit+=c[i]; for(j=limit ; j>=c[i] ; j--) { if(d[j]<d[j-c[i]]+m[i] && d[j-c[i]]>=0) d[j]=d[j-c[i]]+m[i]; } } for(i=0 ; i<=limit ; i++) if(d[i]>=M) { ans=i; break; } } void output(void) { printf("%d",ans); } int main(void) { input(); process(); output(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...