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>
int N, M, m[100] = { 0 }, c[100] = { 0 };
int cost(int i, int mem){
int used, unused;
if (i == N - 1){
if (mem > m[N - 1]) return 10001;
if (mem <= 0) return 0;
return c[N - 1];
}
used = c[i]+cost(i + 1, mem - m[i]);
unused = cost(i + 1, mem);
if (used > unused) return unused;
return used;
}
int main(){
int i;
scanf("%d %d", &N, &M);
for (i = 0; i < N; ++i) scanf("%d", &m[i]);
for (i = 0; i < N; ++i) scanf("%d", &c[i]);
printf("%d\n", cost(0,M));
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... |