201812-1 小明上学
r,y,g = map(int,input().split())
n = int(input())
T = 0
for i in range(n):
k,t = map(int,input().split())
if k == 0:
T += t
elif k == 1:
# red
T += t
elif k == 2:
# yellow
T += (t+r)
elif k == 3:
# green
pass
print(T)
201812-2 小明放学
参考了别人的代码,自己做只有20分:
r,y,g = map(int,input().split())
n = int(input())
T = 0
for i in range(n):
k,t = map(int,input().split())
if k == 0:
T+=t
continue
# safe pass deadline
if k == 1:
t+=g
k = 3
if k == 2:
t+=(r+g)
k = 3
if k == 3:
pass
current_time = (t-T) % (r+y+g)
if current_time > g:
T += (current_time - g)
print(T)
"""
r+y+g = 63s
k = 0 pass
T t cur
10s 5+30s 35-10 = 25s 25<30 pass
21s 2+30+30s 62-21 = 41s 41>30 T+=(41-30)
41s 10s (10-41)% (63) = 32s 32>30 T+=(32-30)
"""