Submission #12207

#TimeUsernameProblemLanguageResultExecution timeMemory
12207gs14004앱 (KOI13_app)C++98
21 / 21
8 ms5192 KiB
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,m,a[105],c[105], dp[105][10005]; int f(int x, int cost){ if(x == 0) return 0; if(~dp[x][cost]) return dp[x][cost]; int ret = f(x-1,cost); if(cost >= c[x-1]){ ret = max(ret,f(x-1,cost - c[x-1]) + a[x-1]); } return dp[x][cost] = ret; } int main(){ memset(dp,-1,sizeof(dp)); scanf("%d %d",&n,&m); for (int i=0; i<n; i++) { scanf("%d",&a[i]); } for (int i=0; i<n; i++) { scanf("%d",&c[i]); } int s = 0, e = 10000; while (s != e) { int mid = (s+e)/2; if(f(n,mid) >= m) e = mid; else s = mid+1; } printf("%d",s); }
#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...