Skip to content

Commit a58fe7d

Browse files
committed
[BOJ] 주유소 / 실버 3 / 30분
https://www.acmicpc.net/problem/13305
1 parent 9d838cb commit a58fe7d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
3+
inp = sys.stdin.readline
4+
5+
n = int(inp())
6+
7+
roads = list(map(int, inp().split()))
8+
oil_prices = list(map(int, inp().split()))
9+
10+
# 최소 비용
11+
answer = 0
12+
# 현재 도시
13+
loc = 0
14+
15+
while True:
16+
# 현재 도시보다 기름값이 적은 곳 찾기
17+
for i in range(loc + 1, n):
18+
if oil_prices[loc] > oil_prices[i] or i == n - 1:
19+
# 이곳까지 가기 위해 현재 도시에서 주유하면서 비용 소모
20+
# 현재 도시의 기름값 * i번 도시까지 가야 할 거리
21+
answer += oil_prices[loc] * sum(roads[loc:i])
22+
loc = i
23+
break
24+
25+
if loc == n - 1:
26+
break
27+
28+
print(answer)

0 commit comments

Comments
 (0)