-
13305번: 주유소
표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 도시의 개수를 나타내는 정수 N(2 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 인접한 두 도시를 연결하는 도로의 길이가 제일 왼쪽 도로부터 N-1
www.acmicpc.net
코드
n = int(input()) length = list(map(int, input().split())) cost = list(map(int, input().split())) s = [0 for i in range(n)] low = cost[0] for i in range(n-1): if i == 0: s[i] = cost[i]*length[i] elif cost[i] < low: low = cost[i] s[i] = s[i-1] + low*length[i] print(max(s))
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 9184번 신나는 함수 실행 (파이썬) (0) 2022.01.01 [백준] 1003번 피보나치 함수 (파이썬) (0) 2022.01.01 [백준] 1541번 잃어버린 괄호 (파이썬) (0) 2022.01.01 [백준] 11399번 ATM (파이썬) (0) 2022.01.01 [백준] 1931번 회의실 배정 (파이썬) (0) 2021.12.29