860.柠檬水找零

class Solution {
public:
    bool lemonadeChange(vector<int>& bills) {
        int c5 = 0, c10 = 0;
        for ( int bill : bills) {
            switch (bill) {
                case 5:
                    c5 ++ ;
                    break;
                case 10:
                    if (c5 == 0) return false;
                    c5 -- ;
                    c10 ++ ;
                    break;
                default:
                    if (c10>0&&c5>0) {
                        c10 -- ; c5 -- ; continue;
                    }
                    if (c5 >= 3) {
                        c5 -= 3; continue;
                    }
                    return false;
                    break;
            }
        }
        return true;
    }
};

模拟题