8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a51c51 commit d246e8fCopy full SHA for d246e8f
0x05/solutions/10773.cpp
@@ -1,11 +1,28 @@
1
-// Authored by : BaaaaaaaaaaarkingDog
+// Authored by : OceanShape
2
// Co-authored by : -
3
-// http://boj.kr/****************
+// http://boj.kr/572b87aed4eb43d9b9084797f5fbace2
4
#include <bits/stdc++.h>
5
using namespace std;
6
7
+int K, ans = 0;
8
+stack<int> s;
9
+
10
int main(void){
11
ios::sync_with_stdio(0);
12
cin.tie(0);
-
-}
13
14
+ cin >> K;
15
+ while(K--){
16
+ int n;
17
+ cin >> n;
18
+ if(n == 0) s.pop(); // 0을 입력할 경우, 가장 최신값(s.top()) 제거
19
+ else s.push(n); // 0 이외의 수를 입력할 경우, 스택에 추가
20
+ }
21
22
+ // 스택에 쌓여 있는 모든 값을 더해줌
23
+ while(!s.empty()){
24
+ ans += s.top();
25
+ s.pop();
26
27
+ cout << ans;
28
+}
0 commit comments