# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
950772 |
2024-03-20T16:42:36 Z |
LCJLY |
Kitchen (BOI19_kitchen) |
C++14 |
|
28 ms |
1364 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
int dp[305*305];
void solve(){
int n,m,k;
cin >> n >> m >> k;
int arr[n];
int counter=0;
bool amos=true;
for(int x=0;x<n;x++){
cin >> arr[x];
counter+=arr[x];
if(arr[x]<k) amos=false;
}
int chef[m];
for(int x=0;x<m;x++){
cin >> chef[x];
}
for(int x=0;x<m;x++){
for(int take=305*305-1;take>=0;take--){
int nxt=take+chef[x];
int add=dp[take]+min(chef[x],n);
if(nxt<305*305){
dp[nxt]=max(dp[nxt],add);
}
}
}
int ans=1e15;
for(int x=0;x<305*305;x++){
//if(x<15) cout << dp[x] << " ";
if(x>=counter&&dp[x]>=n*k){
ans=min(ans,x-counter);
}
}
if(ans>1e9||!amos){
cout << "Impossible\n";
}
else cout << ans;
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1112 KB |
Output is correct |
2 |
Correct |
4 ms |
1116 KB |
Output is correct |
3 |
Correct |
4 ms |
1116 KB |
Output is correct |
4 |
Correct |
4 ms |
1188 KB |
Output is correct |
5 |
Correct |
4 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |