結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2015-05-07 23:26:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 787 bytes |
コンパイル時間 | 1,192 ms |
コンパイル使用メモリ | 87,844 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 20:05:48 |
合計ジャッジ時間 | 1,396 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 5 |
ソースコード
#include <iostream> #include <sstream> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> #include <functional> #include <limits> #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <complex> using namespace std; #define INF (INT_MAX/3) #define PI (2*acos(0.0)) #define EPS (1e-8) typedef long long ll; typedef unsigned long long ull; int main(){ ios_base::sync_with_stdio(0); int N, K, ans = 0; string s; cin >> N >> K >> s; stack<char> st; for(int i = K; i < s.size(); i++){ if(s[i] == '(') st.push(s[i]); else if(s[i] == ')' && !st.empty()) st.pop(); else { ans = i; break; } } cout << ans + 1 << endl; return 0; }