# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
887881 |
2023-12-15T12:18:56 Z |
8pete8 |
Kitchen (BOI19_kitchen) |
C++17 |
|
29 ms |
2904 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
const int mod=1e9+7,mxn=3e5+5,lg=30,inf=1e18,minf=-1e18;
int dp[mxn+10];
int32_t main(){
int n,m,k;cin>>n>>m>>k;
vector<int>food(n),chef(m);
int sum=0,mx=0;
for(int i=0;i<n;i++){
cin>>food[i];
sum+=food[i];
if(food[i]<k){
cout<<"Impossible";
return 0;
}
}
for(int i=0;i<m;i++)cin>>chef[i],mx+=chef[i];
fill(dp,dp+mxn+5,minf);
dp[0]=0;
int ans=inf;
for(int i=0;i<m;i++){
for(int j=mx;j>=0;j--){
if(j-chef[i]>=0&&dp[j-chef[i]]!=minf){
dp[j]=max(dp[j],dp[j-chef[i]]+min(n,chef[i]));
}
}
}
for(int i=sum;i<=mx;i++){
if(dp[i]>=n*k){
ans=i-sum;
break;
}
}
if(ans==inf)cout<<"Impossible";
else cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2744 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2744 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2648 KB |
Output is correct |
13 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2648 KB |
Output is correct |
2 |
Correct |
9 ms |
2652 KB |
Output is correct |
3 |
Correct |
13 ms |
2652 KB |
Output is correct |
4 |
Correct |
21 ms |
2652 KB |
Output is correct |
5 |
Correct |
20 ms |
2652 KB |
Output is correct |
6 |
Correct |
7 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2904 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2744 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2648 KB |
Output is correct |
13 |
Correct |
1 ms |
2648 KB |
Output is correct |
14 |
Correct |
16 ms |
2648 KB |
Output is correct |
15 |
Correct |
9 ms |
2652 KB |
Output is correct |
16 |
Correct |
13 ms |
2652 KB |
Output is correct |
17 |
Correct |
21 ms |
2652 KB |
Output is correct |
18 |
Correct |
20 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
2904 KB |
Output is correct |
23 |
Correct |
1 ms |
2652 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
8 ms |
2652 KB |
Output is correct |
26 |
Correct |
10 ms |
2792 KB |
Output is correct |
27 |
Correct |
5 ms |
2648 KB |
Output is correct |
28 |
Correct |
11 ms |
2652 KB |
Output is correct |
29 |
Correct |
15 ms |
2652 KB |
Output is correct |
30 |
Correct |
29 ms |
2792 KB |
Output is correct |