Submission #12205

#TimeUsernameProblemLanguageResultExecution timeMemory
12205gs14004앱 (KOI13_app)C++98
6.30 / 21
1000 ms5192 KiB
#include <cstdio> #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; 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(){ 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...