File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments