We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f3068d commit a872680Copy full SHA for a872680
1 file changed
JHLEE325/202509/13 BOJ G4 팀 빌딩.md
@@ -0,0 +1,37 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
7
+ public static void main(String[] args) throws IOException {
8
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9
+ StringTokenizer st;
10
11
+ int n = Integer.parseInt(br.readLine());
12
13
+ int[] pgm = new int[n];
14
15
+ st = new StringTokenizer(br.readLine());
16
17
+ for (int i = 0; i < n; i++) {
18
+ pgm[i] = Integer.parseInt(st.nextToken());
19
+ }
20
21
+ int left = 0;
22
+ int right = n - 1;
23
+ int res = 0;
24
25
+ while (left < right) {
26
+ res = Math.max((right - left - 1) * Math.min(pgm[left], pgm[right]), res);
27
+ if (pgm[left] <= pgm[right]) {
28
+ left++;
29
+ } else {
30
+ right--;
31
32
33
34
+ System.out.println(res);
35
36
+}
37
+```
0 commit comments