Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //WTF HOW DOES THIS WORK
- #include<bits/stdc++.h>
- #define pb push_back
- #define mp make_pair
- #define db 0
- #define all(x)(x).begin(),(x).end()
- #define x first
- #define y second
- using namespace std;
- int b[8],p[8];
- int cnt;
- bool a;
- bool is_possible(vector<int>&blood_bag){
- for(int i = 0;i < (int)blood_bag.size();i++){
- if(b[blood_bag[i]] > 0){
- return true;
- }
- }
- return false;
- }
- void distribute(vector<int>blood_bag, int patient_blood_type){
- while(is_possible(blood_bag) && p[patient_blood_type] != 0){
- for(int i = 0;i < (int)blood_bag.size();i++){
- if(b[blood_bag[i]] > 0 || blood_bag[i] == 0){
- b[blood_bag[i]]--;
- p[patient_blood_type]--;
- cnt++;
- break;
- }
- }
- }
- }
- int main(){
- for(int i = 0;i < 8;i++){
- cin >> b[i];
- }
- for(int i = 0;i < 8;i++){
- cin >> p[i];
- }
- //on
- distribute({0},0);
- //op
- distribute({1,0},1);
- //an
- distribute({2,0},2);
- //ap
- distribute({3,2,1,0},3);
- //bn
- distribute({4,0},4);
- //bp
- distribute({5,4,1,0},5);
- //abn
- distribute({6,4,2,0},6);
- //abp
- distribute({7,6,5,4,3,2,1,0},7);
- cout << cnt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement