Advertisement
Promi_38

cf 1236A

Oct 2nd, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.    
  10.     while(t--)
  11.     {
  12.         int a, b, c, cnt = 0;
  13.         cin >> a >> b >> c;
  14.        
  15.         while(b >= 1 && c >= 2)
  16.         {
  17.             b--;
  18.             c -= 2;
  19.             cnt += 3;
  20.             if(b < 1 || c < 2) break;
  21.         }
  22.         while(b >= 2 && a >= 1)
  23.         {
  24.             a--;
  25.             b -= 2;
  26.             cnt += 3;
  27.             if(b < 2 || a < 1) break;
  28.         }
  29.         cout << cnt << endl;
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement