b.py (233B)
1 import fileinput 2 3 p = 50 4 c = 0 5 with fileinput.input() as lines: 6 for line in lines: 7 oldp = p 8 s = 1 if line[0] == "R" else -1 9 p += s * int(line[1:]) 10 c += abs(p) // 100 + (1 if p <= 0 and oldp != 0 else 0) 11 p %= 100 12 13 print(c)