Submission #3140

#TimeUsernameProblemLanguageResultExecution timeMemory
3140club4208앱 (KOI13_app)C++98
21 / 21
4 ms5032 KiB
#include <stdio.h> #define INF 10000001 int d[101][10001]; int m[101], cost[101], n, memory; int max(int a, int b){ if(a<b) return b; else return a; } int main(){ //freopen("input.txt", "r", stdin); //freopen("output.txt', "w", stdout); int i, j, sum=0, res=INF; scanf("%d %d", &n, &memory); for(i=1;i<=n;i++) scanf("%d", &m[i]); for(i=1;i<=n;i++){ scanf("%d", &cost[i]); sum+=cost[i]; } for(i=1;i<=n;i++){ for(j=0;j<=sum;j++){ int a=j-cost[i]; d[i][j]=d[i][j-1]; if(a>=0) d[i][j]=max(d[i-1][a]+m[i], d[i][j]); if(i>0) d[i][j]=max(d[i][j], d[i-1][j]); if(d[i][j]>=memory && res>=j) res=j; } } printf("%d", res); 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...