답안 #1090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090 2013-06-25T05:37:28 Z lmj960417 앱 (KOI13_app) C++
0 / 21
0 ms 40144 KB
#include <stdio.h>
int n,m;
int ba[110],data[110];
int table[10000010];
int main()
{
	int i,a;
	int sum=0;

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf("%d %d",&n,&m);

	for(i=1;i<=n;i++)
	{
		scanf("%d ",&ba[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d ",&data[i]);
		sum+=data[i];
	}

	if(n*m<=80000000)
	{
		for(i=1;i<=m;i++)
		{
			table[i]=sum;
		}
		table[0]=0;
		for(i=1;i<=n;i++)
		{
			for(a=m;a>=0;a--)
			{
				if(a+ba[i]<=m && table[a+ba[i]]>table[a]+data[i])
				{
					table[a+ba[i]]=table[a]+data[i];
				}
			}
		}
		printf("%d\n",table[m]);
	}
	else
	{
		table[0]=1;
		for(i=1;i<=n;i++)
		{
			for(a=sum;a>=0;a--)
			{
				if(table[a] && table[a+data[i]]<table[a]+ba[i])
				{
					table[a+data[i]]=table[a]+ba[i];
				}
			}
		}
		for(i=0;i<=sum;i++)
		{
			if(table[i]-1>=m)
			{
				printf("%d\n",i);
				break;
			}
		}
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 40144 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -