답안 #18754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18754 2016-02-15T04:35:37 Z joonas 앱 (KOI13_app) C
21 / 21
1 ms 1084 KB
#include <stdio.h>
#include <memory.h>
#define max(a,b) a>b?a:b
int main(){
	int i, j, N, M, m[101], c[101], *dp, SZ = 1;
	scanf("%d%d",&N, &M);
	for(i=0; i < N; ++i) scanf("%d",&m[i]);
	for(i=0; i < N; ++i) scanf("%d",&c[i]), SZ += c[i];
	dp = (int*)malloc(SZ+110);
    for(i=1; i <= SZ; ++i) dp[i] = -1;
	for(i=0; i < N; ++i){
		for(j=SZ; j >= 0; --j){
			if( dp[j] >= 0 )
				dp[ j+c[i] ] = max( dp[j+c[i]], dp[j]+m[i] );
		}
	}
	for(i=0; i <= SZ; ++i)
		if( dp[i] >= M ) break;
	printf("%d", i);
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 1 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 1 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct