Last active
May 3, 2020 18:33
-
-
Save andriiburka/d21f3284a7e358d3e699037ced0592b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# QUEUES | |
from collections import deque | |
total_liters = int(input()) | |
people = deque() | |
while True: | |
# Name or END command | |
cmd = input() | |
if cmd == "Start": | |
while True: | |
cmd2 = input() | |
if cmd2 == "End": | |
print(f"{total_liters} liters left") | |
break | |
if "refill" in cmd2: | |
cmd2 = cmd2.split()[1] | |
total_liters += int(cmd2) | |
elif cmd2.isdigit(): | |
print(f"{people[0]} got water") | |
people.popleft() | |
print(people) | |
total_liters -= int(cmd2) | |
else: | |
people.append(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment