""" 0860.1 - Solution 1 - Greedy Approach """
#####################################################################################
# Imports
#####################################################################################
from typing import List
#####################################################################################
# Classes
#####################################################################################
class Solution:
"""Solution Class"""
def lemonadeChange(self, bills: List[int]) -> bool:
"""Lemonade Change Function"""
five = 0
ten = 0
for bill in bills:
if bill == 5:
five += 1
elif bill == 10:
if five == 0:
return False
five -= 1
ten += 1
else: # bill == 20
if ten > 0 and five > 0:
ten -= 1
five -= 1
elif five >= 3:
five -= 3
else:
return False
return True
#####################################################################################
# Functions
#####################################################################################
def testcase():
"""Test Function"""
print(Solution().lemonadeChange([5, 5, 5, 10, 20])) # True
print(Solution().lemonadeChange([5, 5, 10, 10, 20])) # False
print(Solution().lemonadeChange([5, 5, 10])) # True
print(Solution().lemonadeChange([10, 10])) # False
#####################################################################################
# Main
#####################################################################################
if __name__ == "__main__":
testcase()