This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |