用Python寫的,可以把跑壘當作佇列,跑到本壘就pop,HR就clear,實測AC通過
while True:
try:
players = []
for _ in range(9):
players.append(list(input().split()))
b = int(input())
count = 0
base = []
points = 0
k = 1
while count != b:
for i in range(9):
if players[i][k][1] != "B":
if players[i][k] == "HR":
points += len(base) + 1
base.clear()
continue
count += 1
if count % 3 == 0:
base.clear()
if count == b:
break
else:
go = players[i][k][0]
go = int(go)
base = [i+go for i in base]
popCount = 0
for runner in base:
if runner > 3:
popCount += 1
points += 1
for pc in range(popCount):
base.pop(0)
base.append(go)
k += 1
print(points)
except:
break
|