답안 #567157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567157 2022-05-23T08:35:56 Z almothana05 Kitchen (BOI19_kitchen) C++14
100 / 100
179 ms 188160 KB
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
vector<int>num, chef , pow2;
pair<int ,int>mask[40000];
int sub[400][300 * 400];
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 , rechner = 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;
      rechner += numm;
      chef.push_back(numm);
   }
   ///////////////////////////////////////////////////////////////////////////////////////////
   for(int i = 0 ; i < 400 ; i++){
      for(int j = 0 ; j < 400 * 300 ; j++){
         sub[i][j] = mod;
      }
   }
      sub[0][0] = menge * mini;
      for(int i = 0 ; i < koch ; i++){
         for(int j = 0 ; j <= i * 300 ; j++){
            if(sub[i][j] != mod){
               sub[i + 1][j] = min(sub[i + 1][j] ,sub[i][j]);
               sub[i + 1][j + chef[i]] = min(sub[i + 1][j + chef[i]] ,sub[i][j] - min(menge , chef[i])) ;
            // cout << "ja\n";
            }
         }
         // cout << "\n";
      }
      int erg = -1;
      for(int i = re ; i <= rechner ; i++){
         // cout << i << ' ';
         if(sub[koch][i] <= 0){
            // cout << "ja\n";
            erg = i - re ;
            break;   
         }
      }
      if(erg == -1){
         im();
         return 0;
      }
      else{
         cout << erg << "\n";
      }
      return 0;
   
}


Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:30:23: warning: unused variable 'nummer' [-Wunused-variable]
   30 |    int menge,  numm , nummer , koch , mini , re = 0 , rechner = 0;
      |                       ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 188048 KB Output is correct
2 Correct 119 ms 188072 KB Output is correct
3 Correct 97 ms 188072 KB Output is correct
4 Correct 107 ms 188140 KB Output is correct
5 Correct 116 ms 188076 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 95 ms 188044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 188048 KB Output is correct
2 Correct 119 ms 188072 KB Output is correct
3 Correct 97 ms 188072 KB Output is correct
4 Correct 107 ms 188140 KB Output is correct
5 Correct 116 ms 188076 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 95 ms 188044 KB Output is correct
9 Correct 90 ms 188048 KB Output is correct
10 Correct 87 ms 188148 KB Output is correct
11 Correct 89 ms 188036 KB Output is correct
12 Correct 94 ms 188128 KB Output is correct
13 Correct 104 ms 188056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 188152 KB Output is correct
2 Correct 134 ms 188152 KB Output is correct
3 Correct 158 ms 188156 KB Output is correct
4 Correct 169 ms 188156 KB Output is correct
5 Correct 179 ms 188056 KB Output is correct
6 Correct 108 ms 188060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 188104 KB Output is correct
2 Correct 91 ms 188080 KB Output is correct
3 Correct 93 ms 188128 KB Output is correct
4 Correct 95 ms 188080 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 188048 KB Output is correct
2 Correct 119 ms 188072 KB Output is correct
3 Correct 97 ms 188072 KB Output is correct
4 Correct 107 ms 188140 KB Output is correct
5 Correct 116 ms 188076 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 95 ms 188044 KB Output is correct
9 Correct 90 ms 188048 KB Output is correct
10 Correct 87 ms 188148 KB Output is correct
11 Correct 89 ms 188036 KB Output is correct
12 Correct 94 ms 188128 KB Output is correct
13 Correct 104 ms 188056 KB Output is correct
14 Correct 122 ms 188152 KB Output is correct
15 Correct 134 ms 188152 KB Output is correct
16 Correct 158 ms 188156 KB Output is correct
17 Correct 169 ms 188156 KB Output is correct
18 Correct 179 ms 188056 KB Output is correct
19 Correct 108 ms 188060 KB Output is correct
20 Correct 116 ms 188104 KB Output is correct
21 Correct 91 ms 188080 KB Output is correct
22 Correct 93 ms 188128 KB Output is correct
23 Correct 95 ms 188080 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 104 ms 188132 KB Output is correct
26 Correct 113 ms 188116 KB Output is correct
27 Correct 124 ms 188160 KB Output is correct
28 Correct 142 ms 188068 KB Output is correct
29 Correct 166 ms 188132 KB Output is correct
30 Correct 178 ms 188136 KB Output is correct