#include <bits/stdc++.h>
#define DEBUG 1
using namespace std;
namespace output{
void __(short x){cout<<x;}
void __(unsigned x){cout<<x;}
void __(int x){cout<<x;}
void __(long long x){cout<<x;}
void __(unsigned long long x){cout<<x;}
void __(double x){cout<<x;}
void __(long double x){cout<<x;}
void __(char x){cout<<x;}
void __(const char*x){cout<<x;}
void __(const string&x){cout<<x;}
void __(bool x){cout<<(x?"true":"false");}
template<class S,class T>
void __(const pair<S,T>&x){__(DEBUG?"(":""),__(x.first),__(DEBUG?", ":" "),__(x.second),__(DEBUG?")":"");}
template<class T>
void __(const vector<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
template<class T>
void __(const set<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
template<class T>
void __(const multiset<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
template<class S,class T>
void __(const map<S,T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
void pr(){cout<<"\n";}
template<class S,class... T>
void pr(const S&a,const T&...b){__(a);if(sizeof...(b))__(' ');pr(b...);}
}
using namespace output;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
typedef pair<double,double> pdd;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
#define pb push_back
#define fox(i,x,y) for(int i=(x);i<=(y);i++)
#define foxr(i,x,y) for(int i=(y);i>=(x);i--)
const int MN = 303;
int N, M, K, i, j, x, y, sm, lim, dp[MN*MN];
int main(){
scanf("%d%d%d",&N,&M,&K);
for(i=1;i<=N;i++){
scanf("%d",&x);
if(x<K){
printf("Impossible\n");
return 0;
}
sm += x;
}
lim = N*K;
for(j=1;j<MN*MN;j++) dp[j]=-1<<30;
for(i=1;i<=M;i++){
scanf("%d",&x);
for(j=MN*MN-1;j>=x;j--){
dp[j]=max(dp[j],dp[j-x]+min(x,N));
}
}
for(i=sm;i<MN*MN;i++){
if(dp[i]>=lim){
printf("%d\n",i-sm);
return 0;
}
}
printf("Impossible\n");
return 0;
}
Compilation message
kitchen.cpp: In function 'int main()':
kitchen.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&N,&M,&K);
~~~~~^~~~~~~~~~~~~~~~~~~
kitchen.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
~~~~~^~~~~~~~~
kitchen.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
6 ms |
632 KB |
Output is correct |
12 |
Correct |
6 ms |
632 KB |
Output is correct |
13 |
Correct |
7 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
632 KB |
Output is correct |
2 |
Correct |
24 ms |
632 KB |
Output is correct |
3 |
Correct |
31 ms |
632 KB |
Output is correct |
4 |
Correct |
31 ms |
632 KB |
Output is correct |
5 |
Correct |
30 ms |
632 KB |
Output is correct |
6 |
Correct |
23 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
632 KB |
Output is correct |
2 |
Correct |
9 ms |
632 KB |
Output is correct |
3 |
Correct |
8 ms |
632 KB |
Output is correct |
4 |
Correct |
9 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
6 ms |
632 KB |
Output is correct |
12 |
Correct |
6 ms |
632 KB |
Output is correct |
13 |
Correct |
7 ms |
760 KB |
Output is correct |
14 |
Correct |
27 ms |
632 KB |
Output is correct |
15 |
Correct |
24 ms |
632 KB |
Output is correct |
16 |
Correct |
31 ms |
632 KB |
Output is correct |
17 |
Correct |
31 ms |
632 KB |
Output is correct |
18 |
Correct |
30 ms |
632 KB |
Output is correct |
19 |
Correct |
23 ms |
632 KB |
Output is correct |
20 |
Correct |
8 ms |
632 KB |
Output is correct |
21 |
Correct |
9 ms |
632 KB |
Output is correct |
22 |
Correct |
8 ms |
632 KB |
Output is correct |
23 |
Correct |
9 ms |
632 KB |
Output is correct |
24 |
Correct |
5 ms |
128 KB |
Output is correct |
25 |
Correct |
29 ms |
632 KB |
Output is correct |
26 |
Correct |
26 ms |
632 KB |
Output is correct |
27 |
Correct |
19 ms |
632 KB |
Output is correct |
28 |
Correct |
26 ms |
632 KB |
Output is correct |
29 |
Correct |
26 ms |
632 KB |
Output is correct |
30 |
Correct |
31 ms |
632 KB |
Output is correct |