Skip to content

Commit

Permalink
Week 48
Browse files Browse the repository at this point in the history
  • Loading branch information
cje172 committed Apr 1, 2024
1 parent 34059fe commit 60bf517
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 지은/boj/10799.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

stack<char> stk;
int answer = 0;
string s;
cin >> s;

for (int i = 0; i < s.size(); i++) {
if (s[i] == ')') {
stk.pop();

if (s[i - 1] == '(')
answer += stk.size();
else
answer++;
}
else {
stk.push('(');
}
}

cout << answer;

return 0;
}

0 comments on commit 60bf517

Please sign in to comment.