[BOJ]10773번 : 제로
2024. 8. 6. 19:42ㆍAlgorithm
1. problem :
https://www.acmicpc.net/problem/10773
2. solution 1 :
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
stack<int> s;
int K;
cin >> K;
while (K--) {
int op;
cin >> op;
if (op != 0) s.push(op);
else s.pop();
}
int ans = 0;
while (!s.empty()) {
ans += s.top();
s.pop();
}
cout << ans;
}'Algorithm' 카테고리의 다른 글
| [BOJ] 2493: 탑 (0) | 2024.08.07 |
|---|---|
| [BOJ]1874번 : 스택 수열 (0) | 2024.08.06 |
| [BOJ] 1158번 : 요세푸스 (0) | 2024.08.06 |
| [BOJ] 5397번 : 키로거 (0) | 2024.08.05 |
| [BOJ] 1406: 에디터 (0) | 2024.08.05 |