We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1b2be6d commit ba83d50Copy full SHA for ba83d50
1 file changed
2025-09-30/김소희/백준_10773_제로.java
@@ -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