#include<bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define pqueue priority_queue
#define int long long
#define pii pair<int,int>
#define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
//GA AC GA LAKI
using namespace std;
int tc,ans=0,n,m,k,sum;
int INF=10000000;
int a[305];
int b[305];
int bin[30];
int tothour,totdish;
bool cek(){
tothour=0; totdish=0;
for(int i=0;i<=29;i++){
if(bin[i]==1){
tothour+=b[i+1];
totdish+=min(b[i+1],n);
if(b[i+1]<k) return 0;
}
}
if(totdish<k*n) return 0;
if(tothour<sum) return 0;
return 1;
}
void conv(int x){
int temp=x,biton=0;
memset(bin,0,sizeof(bin));
for(int i=29;i>=0;i--){
if(temp>=pow(2,i)){
biton++;
temp-=pow(2,i);
bin[i]=1;
}
}
if(biton>=k&&cek()){
ans=min(ans,tothour-sum);
}
}
main(){
supercepat;
cin>>n>>m>>k;
bool ok=1;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
if(a[i]<k) ok=0;
}
for(int i=1;i<=m;i++) cin>>b[i];
if(!ok){
cout<<"Impossible"<<endl;
return 0;
}
int t1=pow(2,m)-1;
ans=INF;
for(int i=0;i<=t1;i++){
conv(i);
}
if(ans==INF) cout<<"Impossible"<<endl;
else cout<<ans<<endl;
}
Compilation message
kitchen.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
45 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
35 ms |
212 KB |
Output is correct |
11 |
Correct |
33 ms |
212 KB |
Output is correct |
12 |
Correct |
29 ms |
300 KB |
Output is correct |
13 |
Correct |
28 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1054 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
35 ms |
212 KB |
Output is correct |
11 |
Correct |
33 ms |
212 KB |
Output is correct |
12 |
Correct |
29 ms |
300 KB |
Output is correct |
13 |
Correct |
28 ms |
212 KB |
Output is correct |
14 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |