답안 #127015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127015 2019-07-08T19:28:23 Z TadijaSebez Kitchen (BOI19_kitchen) C++11
100 / 100
29 ms 760 KB
#include <bits/stdc++.h>
using namespace std;
const int N=305;
int dp[N*N],a[N],b[N];
int main()
{
	int n,m,k;
	scanf("%i %i %i",&n,&m,&k);
	int A=0;
	bool ok=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
		A+=a[i];
		if(a[i]<k) ok=0;
	}
	for(int i=1;i<N*N;i++) dp[i]=-1e9;
	for(int i=1;i<=m;i++)
	{
		scanf("%i",&b[i]);
		for(int j=N*N-1;j>=b[i];j--)
		{
			dp[j]=max(dp[j],dp[j-b[i]]+min(b[i],n));
		}
	}
	if(!ok) return 0*printf("Impossible\n");
	for(int i=A;i<N*N;i++)
	{
		if(dp[i]>=k*n)
		{
			printf("%i\n",i-A);
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&a[i]);
   ~~~~~^~~~~~~~~~~~
kitchen.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&b[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 4 ms 760 KB Output is correct
12 Correct 3 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 632 KB Output is correct
2 Correct 22 ms 760 KB Output is correct
3 Correct 29 ms 632 KB Output is correct
4 Correct 29 ms 632 KB Output is correct
5 Correct 29 ms 760 KB Output is correct
6 Correct 21 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 760 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 6 ms 760 KB Output is correct
4 Correct 6 ms 632 KB Output is correct
5 Correct 8 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 4 ms 760 KB Output is correct
12 Correct 3 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 25 ms 632 KB Output is correct
15 Correct 22 ms 760 KB Output is correct
16 Correct 29 ms 632 KB Output is correct
17 Correct 29 ms 632 KB Output is correct
18 Correct 29 ms 760 KB Output is correct
19 Correct 21 ms 636 KB Output is correct
20 Correct 6 ms 760 KB Output is correct
21 Correct 6 ms 760 KB Output is correct
22 Correct 6 ms 760 KB Output is correct
23 Correct 6 ms 632 KB Output is correct
24 Correct 8 ms 632 KB Output is correct
25 Correct 22 ms 760 KB Output is correct
26 Correct 25 ms 632 KB Output is correct
27 Correct 16 ms 760 KB Output is correct
28 Correct 24 ms 760 KB Output is correct
29 Correct 25 ms 724 KB Output is correct
30 Correct 29 ms 632 KB Output is correct