Skip to content

Instantly share code, notes, and snippets.

@modos
Created October 31, 2022 00:04
Show Gist options
  • Save modos/922fc56dd318bff35d0ca3aa0f3de54d to your computer and use it in GitHub Desktop.
Save modos/922fc56dd318bff35d0ca3aa0f3de54d to your computer and use it in GitHub Desktop.
باقر خسته‌ست ولی بی‌فرهنگ نه
numof, to_univ = [int(i) for i in input().split()]
redlamps = list()
# LENGTH , RED , GREEN
for i in range(numof):
redlamps.append([int(i) for i in input().split()])
which = 0
where = 0
while where < to_univ:
iso = False
# print('WHERE:', where)
# print('Time:', which)
# print()
for i in redlamps:
iso = False
if i[0] == where:
# print(i[1] , which % (i[1] + i[2]))
if i[1] > which % (i[1] + i[2]):
which += i[1] - which % (i[1] + i[2])
else:
iso = True
if iso:
which += 1
where += 1
print(which + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment