답안 #5356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5356 2014-04-09T11:04:31 Z baneling100 앱 (KOI13_app) C++
21 / 21
0 ms 1128 KB
#include <stdio.h>

int N, M, m[101], c[101], d[10001], ans;

void input(void)
{
    int i, sum=0;

    scanf("%d %d",&N,&M);
    for(i=1 ; i<=N ; i++)
        scanf("%d",&m[i]);
    for(i=1 ; i<=N ; i++)
    {
        scanf("%d",&c[i]);
        sum+=c[i];
    }
    for(i=1 ; i<=sum ; i++)
        d[i]=-1;
}

void process(void)
{
    int i, j, limit=0;

    for(i=1 ; i<=N ; i++)
    {
        limit+=c[i];
        for(j=limit ; j>=c[i] ; j--)
        {
            if(d[j]<d[j-c[i]]+m[i] && d[j-c[i]]>=0)
                d[j]=d[j-c[i]]+m[i];
        }
    }
    for(i=0 ; i<=limit ; i++)
        if(d[i]>=M)
        {
            ans=i;
            break;
        }
}

void output(void)
{
    printf("%d",ans);
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
6 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
6 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
6 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
6 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct
5 Correct 0 ms 1128 KB Output is correct
6 Correct 0 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Correct 0 ms 1128 KB Output is correct
4 Correct 0 ms 1128 KB Output is correct