Skip to content

Commit 5429531

Browse files
authored
BOJ #18228: 펭귄추락대책위원회
1 parent e32d51d commit 5429531

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

BOJ/18228/Main.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Author: Minho Kim (ISKU)
3+
* Date: December 30, 2019
4+
* E-mail: minho.kim093@gmail.com
5+
*
6+
* https://github.com/ISKU/Algorithm
7+
* https://www.acmicpc.net/problem/18228
8+
*/
9+
10+
import java.io.*;
11+
import java.util.*;
12+
13+
public class Main {
14+
public static void main(String[] args) throws Exception {
15+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
16+
int N = Integer.parseInt(br.readLine());
17+
18+
StringTokenizer st = new StringTokenizer(br.readLine());
19+
int min = Integer.MAX_VALUE;
20+
int answer = 0;
21+
for (int i = 0; i < N; i++) {
22+
int ice = Integer.parseInt(st.nextToken());
23+
if (ice == -1) {
24+
answer = min;
25+
min = Integer.MAX_VALUE;
26+
continue;
27+
}
28+
29+
min = Math.min(min, ice);
30+
}
31+
answer += min;
32+
33+
System.out.println(answer);
34+
}
35+
}

0 commit comments

Comments
 (0)