-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathD.java
More file actions
28 lines (25 loc) · 836 Bytes
/
Copy pathD.java
File metadata and controls
28 lines (25 loc) · 836 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
package atcoder.m_solutions;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public final class D {
public static void main(String[] args) {
final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int n = Integer.parseInt(in.nextLine());
final int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
in.nextLine();
long curr = 1000;
for (int i = 1; i < arr.length; i++) {
if (arr[i] - arr[i - 1] > 0) {
final long buy = curr / arr[i - 1];
curr %= arr[i - 1];
final long profit = arr[i] * buy;
curr += profit;
}
}
System.out.println(curr);
}
}