Submission #12207

# Submission time Handle Problem Language Result Execution time Memory
12207 2014-12-24T08:44:44 Z gs14004 앱 (KOI13_app) C++
21 / 21
8 ms 5192 KB
#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 time Memory Grader output
1 Correct 0 ms 5192 KB Output is correct
2 Correct 0 ms 5192 KB Output is correct
3 Correct 0 ms 5192 KB Output is correct
4 Correct 0 ms 5192 KB Output is correct
5 Correct 0 ms 5192 KB Output is correct
6 Correct 0 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5192 KB Output is correct
2 Correct 0 ms 5192 KB Output is correct
3 Correct 0 ms 5192 KB Output is correct
4 Correct 0 ms 5192 KB Output is correct
5 Correct 0 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5192 KB Output is correct
2 Correct 0 ms 5192 KB Output is correct
3 Correct 4 ms 5192 KB Output is correct
4 Correct 0 ms 5192 KB Output is correct
5 Correct 0 ms 5192 KB Output is correct
6 Correct 4 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5192 KB Output is correct
2 Correct 0 ms 5192 KB Output is correct
3 Correct 4 ms 5192 KB Output is correct
4 Correct 0 ms 5192 KB Output is correct
5 Correct 0 ms 5192 KB Output is correct
6 Correct 0 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5192 KB Output is correct
2 Correct 8 ms 5192 KB Output is correct
3 Correct 8 ms 5192 KB Output is correct
4 Correct 8 ms 5192 KB Output is correct
5 Correct 4 ms 5192 KB Output is correct
6 Correct 4 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5192 KB Output is correct
2 Correct 0 ms 5192 KB Output is correct
3 Correct 4 ms 5192 KB Output is correct
4 Correct 8 ms 5192 KB Output is correct
5 Correct 0 ms 5192 KB Output is correct
6 Correct 8 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5192 KB Output is correct
2 Correct 4 ms 5192 KB Output is correct
3 Correct 4 ms 5192 KB Output is correct
4 Correct 4 ms 5192 KB Output is correct