파이썬 알고리즘/BOJ

[Algorithm] 백준 #13305 주유소

walbe0528 2024. 7. 8. 00:54
728x90
반응형
import sys
input = sys.stdin.readline

N = int(input())
distances = list(map(int, input().split()))
costs = list(map(int, input().split()))

# 처음에는 시작지점에서 기름 넣고 시작
total = costs[0]*distances[0]
min_cost = costs[0]

for i in range(1, N-1):
    if min_cost > costs[i]:
        min_cost = costs[i]
    total += min_cost*distances[i]
print(total)

 

풀엇는데 또또또 까먹음..

 

728x90