답안 #584249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584249 2022-06-27T05:34:33 Z temporary_juggernaut Kitchen (BOI19_kitchen) C++14
100 / 100
33 ms 696 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
    #define printl(args...) printf(args)
#else
    #define printl(args...) 0
#endif
int dp[100005];
int a[305];
int n,m,k;
int sum;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]<k)return puts("Impossible"),0;
		sum+=a[i];
	}
	for(int i=1;i<100005;i++)dp[i]=-2e9;
	for(int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);
      	int pivot=min(x,n);
		for(int j=100000;j>=x;j--)umax(dp[j],dp[j-x]+pivot);
	}
	int ans=2e9;
	for(int i=0;i<100005;i++)
	if(dp[i]>=k*n&&i>=sum)umin(ans,i-sum);
	if(ans==(int)2e9)return puts("Impossible"),0;
	cout<<ans;
}

Compilation message

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