Advertisement
wgma

Untitled

Sep 26th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. //WTF HOW DOES THIS WORK
  2. #include<bits/stdc++.h>
  3. #define pb push_back
  4. #define mp make_pair
  5. #define db 0
  6. #define all(x)(x).begin(),(x).end()
  7. #define x first
  8. #define y second
  9. using namespace std;
  10.  
  11. int b[8],p[8];
  12. int cnt;
  13. bool a;
  14.  
  15. bool is_possible(vector<int>&blood_bag){
  16.     for(int i = 0;i < (int)blood_bag.size();i++){
  17.         if(b[blood_bag[i]] > 0){
  18.             return true;
  19.         }
  20.     }
  21.     return false;
  22. }
  23. void distribute(vector<int>blood_bag, int patient_blood_type){
  24.     while(is_possible(blood_bag) && p[patient_blood_type] != 0){
  25.         for(int i = 0;i < (int)blood_bag.size();i++){
  26.             if(b[blood_bag[i]] > 0 || blood_bag[i] == 0){
  27.                 b[blood_bag[i]]--;
  28.                 p[patient_blood_type]--;
  29.                 cnt++;
  30.                 break;
  31.             }
  32.         }
  33.     }
  34. }
  35.  
  36. int main(){
  37.     for(int i = 0;i < 8;i++){
  38.         cin >> b[i];
  39.     }
  40.     for(int i = 0;i < 8;i++){
  41.         cin >> p[i];
  42.     }
  43.     //on
  44.     distribute({0},0);
  45.     //op
  46.     distribute({1,0},1);
  47.     //an
  48.     distribute({2,0},2);
  49.     //ap
  50.     distribute({3,2,1,0},3);
  51.     //bn
  52.     distribute({4,0},4);
  53.     //bp
  54.     distribute({5,4,1,0},5);
  55.     //abn
  56.     distribute({6,4,2,0},6);
  57.     //abp
  58.     distribute({7,6,5,4,3,2,1,0},7);
  59.     cout << cnt << endl;
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement