Problem Solving
20. 지능형 기차
굥깡
2022. 9. 12. 06:10
728x90
2455번: 지능형 기차
최근에 개발된 지능형 기차가 1번역(출발역)부터 4번역(종착역)까지 4개의 정차역이 있는 노선에서 운행되고 있다. 이 기차에는 타거나 내리는 사람 수를 자동으로 인식할 수 있는 장치가 있다.
www.acmicpc.net
매 플랫폼에서 사람이 타고 내리는 와중에 기차 내 인원이 가장 많을 때 그 수를 구하는 문제
platform1 = list(map(int, input().split()))
platform2 = list(map(int, input().split()))
platform3 = list(map(int, input().split()))
platform4 = list(map(int, input().split()))
train = platform1 + platform2 + platform3 + platform4
now = 0
max = 0
for i in range(len(train)):
if i % 2 == 1:
now = now + train[i]
if max < now:
max = now
else:
now = now - train[i]
print(max)
input을 더 효율적으로 처리하는 방법을 없을까..