Submission #799527

# Submission time Handle Problem Language Result Execution time Memory
799527 2023-07-31T15:38:41 Z andecaandeci Kitchen (BOI19_kitchen) C++17
0 / 100
1000 ms 20712 KB
#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);
  }
  for(int i=0;i<m;i++){
    cout<<bin[i]<<" ";
  }
  cout<<endl;
  cout<<ans<<endl;
}
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:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
# 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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 20712 KB Time limit exceeded
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 -