# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
567192 |
2022-05-23T09:03:13 Z |
Majid |
Kitchen (BOI19_kitchen) |
C++17 |
|
37 ms |
1032 KB |
#include<bits/stdc++.h>
using namespace std;
//Types
using ll = long long;
using db = double;
//Vectors
#define pb push_back
#define sz(vec) ((ll)vec.size())
#define all(vec) vec.begin(), vec.end()
//things
#define f first
#define s second
const int SMALLINF = 1e9 + 7;
const ll BIGINF = ((ll)1e18) + 7;
#define Speeed ios::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL);
ll t[90007];
void solve(){
ll n, m, k, sum = 0, sum2 = 0;
cin>>n>>m>>k;
bool imp = false;
if(m<k)imp = true;
vector<ll> vec(n), hr(m);
for(ll i = 0; i < n; i++){
cin>>vec[i];
sum+=vec[i];
if(vec[i]<k)imp = true;
}
for(ll i = 0; i < m; i++){
cin>>hr[i];
sum2+=hr[i];
}
if(sum>sum2)imp = true;
sort(all(hr));
// 5 5 5
//
// 14 1
if(m<=2){
for(ll i = 0; i < m; i++){
if(hr[0]<n)imp = true;
}
if(!imp)cout<<sum2 - sum;
else cout<<"Impossible";
}
else{
t[0] = 1;
for(ll i = 0; i < m; i++){
for(ll j = 90007; j>= hr[i]; j--){
t[j] = (t[j] or t[j-hr[i]]);
}
}
ll ans = -1;
for(ll i = sum; i <= 90007; i++){
if(t[i]!=0){
ans = i;
break;
}
}
if(ans==-1 or imp)cout<<"Impossible";
else cout<<ans - sum;
}
}
int main(){
Speeed
ll t=1;
// cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1032 KB |
Output is correct |
2 |
Correct |
27 ms |
980 KB |
Output is correct |
3 |
Correct |
37 ms |
1016 KB |
Output is correct |
4 |
Correct |
37 ms |
980 KB |
Output is correct |
5 |
Correct |
34 ms |
1016 KB |
Output is correct |
6 |
Correct |
35 ms |
1008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |