#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
4 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
1084 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1088 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
1084 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
1084 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
1084 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
1084 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |