-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ13305.java
More file actions
34 lines (30 loc) · 914 Bytes
/
BOJ13305.java
File metadata and controls
34 lines (30 loc) · 914 Bytes
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
package ¹éÁØ;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class BOJ13305 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
long[] length = new long[N-1];
long[] cost = new long[N];
for(int i = 0; i < N-1; i++) {
length[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
for(int i = 0; i < N; i++) {
cost[i] = Integer.parseInt(st.nextToken());
}
long sum = 0;
long minCost = cost[0];
for(int i = 0; i < N-1; i++) {
if(cost[i] < minCost) {
minCost = cost[i];
}
sum += minCost * length[i];
}
System.out.print(sum);
}
}