import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int n = kb.nextInt();
int[] distance = new int[n-1];
int[] cost = new int[n];
for(int i=0; i<n-1; i++){
distance[i] = kb.nextInt();
}
for(int i=0; i<n; i++){
cost[i] = kb.nextInt();
}
long minCost = cost[0];
long sum = 0;
for(int i=0; i<n-1; i++){
if (minCost>cost[i]){
minCost = cost[i];
}
sum += minCost*distance[i];
}
System.out.println(sum);
}
}
'공부기록 > 백준' 카테고리의 다른 글
[백준] 1406번 에디터 (1) | 2024.01.14 |
---|---|
[백준] 13300번 방 배정 (0) | 2024.01.13 |
[백준] 1874번 스택 수열 (1) | 2024.01.09 |
[백준] 1543번 문서 검색 (0) | 2024.01.09 |
[백준] 1026번 보물 (0) | 2024.01.08 |