Submission #567076

# Submission time Handle Problem Language Result Execution time Memory
567076 2022-05-23T07:52:56 Z almothana05 Kitchen (BOI19_kitchen) C++14
31 / 100
9 ms 980 KB
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
vector<int>num, chef , pow2;
pair<int ,int>mask[40000];
void im(){
   cout << "Impossible\n";
}
string bi(int x){
   string cmp;
   while(x){
      if(x % 2 == 0){
         cmp += '0';
      }
      else{
         cmp += '1';
      }
      x /= 2;
   }
   return cmp;
}
int main(){
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
   for(int i = 1; i < 1000000 ; i *= 2){
      pow2.push_back(i);
   }
   int menge,  numm , nummer , koch , mini , re = 0;
   cin >> menge >> koch >> mini;
   if(koch < mini){
      im();
      return 0;
   }
   for(int i = 0 ; i < menge ; i++){
      cin >> numm;
      re += numm;
      num.push_back(numm);
      if(numm < mini){
         im();
         return 0;
      }
   }
   for(int i = 0 ; i < koch ; i++){
      cin >> numm;
      chef.push_back(numm);
   }
   mask[0] = {menge * mini , re};
   string s;
   for(int i = 1 ; i < pow2[koch] ; i++){
      s = bi(i);
      for(int j = 0 ; j < s.size() ; j++){
         if(s[j] == '1'){
            mask[i] = mask[i - pow2[j]];
            mask[i].first -= min(menge , chef[j]);
            mask[i].second -= chef[j];
         }
      }
   }
   int erg = mod;
   for(int i = 0 ; i < pow2[koch] ; i++){
      if(mask[i].first <= 0 && mask[i].second <= 0){
         erg = min(erg , -mask[i].second);
      }
   }
   if(erg == mod){
      im();
      return 0;
   }
   assert(erg>= 0);
   cout << erg << "\n";
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:52:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |       for(int j = 0 ; j < s.size() ; j++){
      |                       ~~^~~~~~~~~~
kitchen.cpp:29:23: warning: unused variable 'nummer' [-Wunused-variable]
   29 |    int menge,  numm , nummer , koch , mini , re = 0;
      |                       ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 6 ms 468 KB Output is correct
10 Correct 7 ms 468 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 6 ms 468 KB Output is correct
10 Correct 7 ms 468 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Runtime error 8 ms 980 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -