Advertisement
Promi_38

cf 519C

May 1st, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int xp, nb, cnt = 0;
  6.     scanf("%d %d", &xp, &nb);
  7.    
  8.     while((xp >= 1 && nb >= 2) || (xp >= 2 && nb >= 1))
  9.     {
  10.         cnt++;
  11.        
  12.         if(xp <= nb)
  13.         {
  14.             xp--;
  15.             nb -= 2;
  16.         }
  17.        
  18.         else
  19.         {
  20.             nb--;
  21.             xp -= 2;
  22.         }
  23.     }
  24.    
  25.     printf("%d\n", cnt);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement