Submission #8010

#TimeUsernameProblemLanguageResultExecution timeMemory
8010paulsohn앱 (KOI13_app)C++98
21 / 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 = 0; 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]; } else if (cost == c[i]){ if(used < m[i]) used=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...