-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path팀 빌딩.java
More file actions
33 lines (25 loc) · 896 Bytes
/
팀 빌딩.java
File metadata and controls
33 lines (25 loc) · 896 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] arr = new int[n];
StringTokenizer st = new StringTokenizer(br.readLine());
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
int l = 0, r = n - 1, Max = Integer.MIN_VALUE;
while (l < r) {
Max = Math.max(Max, (r - l - 1) * Math.min(arr[r], arr[l]));
if (arr[l] > arr[r]) {
r--;
} else {
l++;
}
}
System.out.println(Max);
}
}