File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ //https://www.acmicpc.net/problem/17127
2+ import java .io .BufferedReader ;
3+ import java .io .IOException ;
4+ import java .io .InputStreamReader ;
5+ import java .util .StringTokenizer ;
6+
7+ public class BOJ_S5_17127_벚꽃이정보섬에피어난이유 {
8+ public static void main (String [] args ) throws IOException {
9+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
10+
11+ int N = Integer .parseInt (br .readLine ());
12+ int [] trees = new int [N ];
13+
14+ StringTokenizer st = new StringTokenizer (br .readLine ());
15+ for (int i = 0 ; i < N ; i ++) {
16+ trees [i ] = Integer .parseInt (st .nextToken ());
17+ }
18+
19+ int max = 0 ;
20+
21+ // i: 기준점 1
22+ for (int i = 1 ; i < N ; i ++) {
23+ int a = 1 ;
24+ for (int x = 0 ; x < i ; x ++) {
25+ a *= trees [x ];
26+ }
27+
28+ // j: 기준점 2
29+ for (int j = i +1 ; j < N ; j ++) {
30+ int b = 1 ;
31+ for (int x = i ; x < j ; x ++) {
32+ b *= trees [x ];
33+ }
34+
35+ // k: 기준점 3
36+ for (int k = j +1 ; k < N ; k ++) {
37+ int c = 1 ;
38+ for (int x = j ; x < k ; x ++) {
39+ c *= trees [x ];
40+ }
41+
42+ int d = 1 ;
43+ for (int x = k ; x < N ; x ++) {
44+ d *= trees [x ];
45+ }
46+
47+ int sum = a + b + c + d ;
48+ max = Math .max (max , sum );
49+ }
50+ }
51+ }
52+
53+ System .out .println (max );
54+
55+
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments