ulfben

Jerry & The Gilmore Girls

Sep 12th, 2016
544
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. bool tickets(const std::vector<int>& customers) {
  2.     int fifties = 0, tf = 0; //tf = twentyfives
  3.     for (int bill : customers) {       
  4.         if (bill == 25) { tf++; } //need 0 change
  5.         else if (bill == 50) {
  6.             if (--tf < 0) return false; //needs 25 change
  7.             fifties++;
  8.         }
  9.         else { //bill == 100, needs (50+25) OR (25*3) change
  10.             if (fifties > 0 && tf > 0) { fifties--; tf--; }
  11.             else if ((tf -= 3) < 0) { return false; }
  12.         }      
  13.     }
  14.     return true;
  15. }
Advertisement
Comments
  • Rteuixl
    125 days
    # text 0.21 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
    6.  
    7. Remove the @
  • Comment was deleted
Add Comment
Please, Sign In to add comment