Submission #1066

#TimeUsernameProblemLanguageResultExecution timeMemory
1066tncks0121앱 (KOI13_app)C++98
21 / 21
4 ms5192 KiB
#include<stdio.h> FILE *in=stdin; FILE *out=stdout; int n, m; int memory[105], cost[105], d[105][10005]; int dab; int main () { int t, i, j; fscanf(in, "%d%d", &n, &m); for (i=1;i<=n;i++) fscanf(in, "%d", &memory[i]); for (i=1;i<=n;i++) fscanf(in, "%d", &cost[i]); for (i=0;i<=10000;i++) d[0][i] = 0; for (i=1;i<=n;i++) { for (j=0;j<=10000;j++) { d[i][j] = d[i-1][j]; if (j-cost[i] >= 0 && d[i][j] < d[i-1][j-cost[i]]+memory[i]) d[i][j] = d[i-1][j-cost[i]]+memory[i]; } } dab = -1; for (i=0;i<=10000;i++) { if (d[n][i] >= m) { dab = i; break; } }fprintf(out, "%d\n", dab); 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...