Skip to content

Commit ee5cdfd

Browse files
authored
Merge pull request #880 from AlgorithmWithGod/lkhyun
[20250913] BOJ / G4 / 팀 빌딩 / 이강현
2 parents fe59ed9 + 97cf987 commit ee5cdfd

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
7+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
9+
static StringTokenizer st;
10+
static int N;
11+
static int[] arr;
12+
13+
public static void main(String[] args) throws IOException {
14+
N = Integer.parseInt(br.readLine());
15+
arr = new int[N];
16+
17+
st = new StringTokenizer(br.readLine());
18+
for (int i = 0; i < N; i++) {
19+
arr[i] = Integer.parseInt(st.nextToken());
20+
}
21+
int left = 0;
22+
int right = N-1;
23+
int ans = 0;
24+
while(left < right){
25+
if(arr[left] <= arr[right]){
26+
ans = Math.max(ans,(right-left-1)*arr[left]);
27+
left++;
28+
}else{
29+
ans = Math.max(ans,(right-left-1)*arr[right]);
30+
right--;
31+
}
32+
}
33+
bw.write(ans+"");
34+
bw.close();
35+
}
36+
}
37+
```

0 commit comments

Comments
 (0)