Submission #18754

#TimeUsernameProblemLanguageResultExecution timeMemory
18754joonas앱 (KOI13_app)C11
21 / 21
1 ms1084 KiB
#include <stdio.h> #include <memory.h> #define max(a,b) a>b?a:b int main(){ int i, j, N, M, m[101], c[101], *dp, SZ = 1; 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]), SZ += c[i]; dp = (int*)malloc(SZ+110); for(i=1; i <= SZ; ++i) dp[i] = -1; for(i=0; i < N; ++i){ for(j=SZ; j >= 0; --j){ if( dp[j] >= 0 ) dp[ j+c[i] ] = max( dp[j+c[i]], dp[j]+m[i] ); } } for(i=0; i <= SZ; ++i) if( dp[i] >= M ) break; printf("%d", i); 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...