Submission #12826

#TimeUsernameProblemLanguageResultExecution timeMemory
12826lingxiang앱 (KOI13_app)C++98
21 / 21
4 ms4996 KiB
#include <stdio.h> int mem[100]; int cost[100]; int d[100][10001]; int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, m; int i, j; int maxcost=0; scanf("%d %d", &n, &m); for(i=0; i<n; i++) { scanf(" %d", &mem[i]); } for(i=0; i<n; i++) { scanf(" %d", &cost[i]); maxcost+=cost[i]; } for(i=0; i<n; i++) for(j=0; j<=maxcost; j++) d[i][j]=-1; d[0][0]=0; d[0][cost[0]]=mem[0]; for(i=1; i<n; i++) { for(j=0; j<=maxcost; j++) d[i][j]=d[i-1][j]; for(j=cost[i]; j<=maxcost; j++) { if(d[i-1][j-cost[i]]!=-1 && d[i-1][j]<d[i-1][j-cost[i]]+mem[i]) { d[i][j]=d[i-1][j-cost[i]]+mem[i]; } } } for(j=0; j<=maxcost; j++) { if(d[n-1][j]>=m) { printf("%d", j); break; } } 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...