原题链接:https://leetcode.com/problems/lemonade-change/
bool lemonadeChange(vector<int>& bills) { int tens = 0, fives = 0; for (auto x : bills) { if (x == 5) { fives ++ ; } else if (x == 10) { if (fives) { fives -- ; tens ++ ; } else { return false; } } else if (x == 20) { int t = 15; if (tens) { tens -- ; t -= 10; } while (t && fives) { fives -- ; t -= 5; } if (t) { return false; } } } return true; }