Skip to content

Instantly share code, notes, and snippets.

@zigzackey
Created March 31, 2016 21:34
Show Gist options
  • Save zigzackey/655b5c2b4c7ad98c894456113f571f8d to your computer and use it in GitHub Desktop.
Save zigzackey/655b5c2b4c7ad98c894456113f571f8d to your computer and use it in GitHub Desktop.
from collections import deque
if __name__ == '__main__':
n, q = map(int, input().split())
Q = deque()
for i in range(n):
name, time = input().split()
Q.append([name, int(time)])
sum = 0
while Q:
qt = Q.popleft()
if qt[1] <= q:
sum += qt[1]
print(qt[0], sum)
else:
sum += q
qt[1] -= q
Q.append(qt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment