목차

주유소

ps
링크acmicpc.net/…
출처BOJ
문제 번호13305
문제명주유소
레벨실버 4
분류

그리디

시간복잡도O(n)
인풋사이즈n<=100,000
사용한 언어Python
제출기록46788KB / 104ms
최고기록92ms
해결날짜2022/02/08

풀이

코드

"""Solution code for "BOJ 13305. 주유소".

- Problem link: https://www.acmicpc.net/problem/13305
- Solution link: http://www.teferi.net/ps/problems/boj/13305

Tags: [Greedy]
"""

INF = float('inf')


def main():
    N = int(input())  # pylint: disable=unused-variable
    distances = [int(x) for x in input().split()]
    prices = [int(x) for x in input().split()]

    min_price = INF
    answer = 0
    for price, distance in zip(prices, distances):
        if price < min_price:
            min_price = price
        answer += min_price * distance

    print(answer)


if __name__ == '__main__':
    main()