-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path13305.java
35 lines (28 loc) · 1017 Bytes
/
13305.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine(). split(" ");
long answer = 0;
int N = Integer.parseInt(input[0]);
long[] distances = new long[N - 1];
int[] prices = new int[N];
input = br.readLine().split(" ");
for(int i = 0; i < N - 1; i++) {
distances[i] = Integer.parseInt(input[i]);
}
input = br.readLine().split(" ");
for(int i = 0; i < N; i++) {
prices[i] = Integer.parseInt(input[i]);
}
br.close();
int minPrice = Integer.MAX_VALUE;
for(int i = 0; i < N - 1; i++) {
if(prices[i] < minPrice) minPrice = prices[i];
answer += minPrice * distances[i];
}
System.out.println(answer);
}
}