Skip to content

Commit ba83d50

Browse files
authored
Create 백준_10773_제로.java
1 parent 1b2be6d commit ba83d50

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
import java.io.*;
3+
public class Main {
4+
public static void main(String[] args) throws IOException {
5+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
int N = Integer.parseInt(br.readLine());
7+
8+
LinkedList<Integer> list = new LinkedList<>();
9+
for(int i=0; i<N; i++){
10+
int num = Integer.parseInt(br.readLine());
11+
if(num==0){
12+
list.removeLast(); continue;
13+
}
14+
list.add(num);
15+
}
16+
int sum=0;
17+
for(int i :list){
18+
sum+= i;
19+
}
20+
System.out.print(sum);
21+
}
22+
}

0 commit comments

Comments
 (0)