Submission #7997

#TimeUsernameProblemLanguageResultExecution timeMemory
7997paulsohn앱 (KOI13_app)C++98
0 / 21
0 ms4996 KiB
#include <stdio.h> int N, M, m[100] = { 0 }, c[100] = { 0 }; int maxmem[100][10001] = { 0 }; int main(){ int totalc = 0, minc; scanf("%d %d", &N, &M); for (int i = 0; i < N; ++i){ scanf("%d", &m[i]); } for (int i = 0; i < N; ++i){ scanf("%d", &c[i]); totalc += c[i]; } maxmem[0][c[0]] = m[0]; for (int i = 1; i < N; ++i){ for (int cost = 1; cost <= totalc; ++cost){ int used=0, unused; if (cost>c[i] && maxmem[i - 1][cost - c[i]]){ used = maxmem[i - 1][cost - c[i]] + m[i]; } unused = maxmem[i-1][cost]; maxmem[i][cost] = (used > unused ? used : unused); } } for (minc = 0; minc <= totalc; ++minc){ if (maxmem[N - 1][minc] >= M) break; } printf("%d\n", minc); 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...