diff --git a/bomik0221/README.md b/bomik0221/README.md index cee5194..df8cdda 100644 --- a/bomik0221/README.md +++ b/bomik0221/README.md @@ -18,5 +18,6 @@ | 14차시 | 2024.02.15 | 위상정렬 | [줄 세우기](https://www.acmicpc.net/problem/2252) | [#57](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/57) | | 15차시 | 2024.02.18 | 위상정렬 | [문제집](https://www.acmicpc.net/problem/1766) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/60) | | 16차시 | 2024.02.24 | DP | [돌 게임](https://www.acmicpc.net/problem/9655) | [#67](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/67) | +| 17차시 | 2024.02.27 | 스택 | [괄호 끼워넣기](https://www.acmicpc.net/problem/11899) | [#71](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/71) | --- diff --git "a/bomik0221/\354\212\244\355\203\235/240227.cpp" "b/bomik0221/\354\212\244\355\203\235/240227.cpp" new file mode 100644 index 0000000..1631bde --- /dev/null +++ "b/bomik0221/\354\212\244\355\203\235/240227.cpp" @@ -0,0 +1,18 @@ +#include +#include + +int main() { + std::string S; + std::cin >> S; + std::stackstack; + + for (int num = 0; num < S.size(); num++) { + if (!stack.empty() && stack.top() == 1 && S[num] == ')') stack.pop(); + else { + if (S[num] == '(') stack.push(1); + else stack.push(2); + } + } + std::cout << stack.size(); + return 0; +}