B - Glass and Mug Editorial by evima
Another SolutionYou can “transfer water from the mug to the glass until the mug is empty or the glass is filled with water” in time even if you transfer \(1\) milliliter at a time.
Sample Implementation (Python)
K, G, M = map(int, input().split())
g, m = 0, 0
for _ in range(K):
if g == G:
g = 0
elif m == 0:
m = M
else:
while m > 0 and g < G:
m -= 1
g += 1
print(g, m)
posted:
last update: