Submission #8003

# Submission time Handle Problem Language Result Execution time Memory
8003 2014-08-27T05:38:36 Z paulsohn 앱 (KOI13_app) C++
0 / 21
0 ms 4996 KB
#include <stdio.h>
int N, M, m[100] = { 0 }, c[100] = { 0 };
int maxmem[100][10001] = { 0 };
int main(){
	int totalc = 0, minc;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < N; ++i){
		scanf("%d", &m[i]);
	}
	for (int i = 0; i < N; ++i){
		scanf("%d", &c[i]);
		totalc += c[i];
	}
	maxmem[0][c[0]] = m[0];
	for (int i = 1; i < N; ++i){
		for (int cost = 1; cost <= totalc; ++cost){
			int used=0, unused;
			if (cost>c[i] && maxmem[i - 1][cost - c[i]]){
				used = maxmem[i - 1][cost - c[i]] + m[i];
			}
			unused = maxmem[i-1][cost];
			maxmem[i][cost] = (used > unused ? used : unused);
		}
	}
	for (minc = 0; minc <= totalc; ++minc){
		if (maxmem[N - 1][minc] >= M) break;
	}
	printf("%d\n", minc);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4996 KB Output is correct
2 Incorrect 0 ms 4996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4996 KB Output is correct
2 Incorrect 0 ms 4996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4996 KB Output is correct
2 Incorrect 0 ms 4996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4996 KB Output isn't correct
2 Halted 0 ms 0 KB -