結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2016-10-18 15:14:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 65,892 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:17:11 |
合計ジャッジ時間 | 1,115 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <cmath> #include <vector> #include <sstream> // istringstream #include <algorithm> // sort, reverse #include <utility> // pair #include <cfloat> // DBL_MAX typedef long long ll; using namespace std; int main(){ //// input int N, K; string str; cin >> N >> K >> str; //// main int idx=K-1,count=1; if(str[idx]=='('){ while(++idx){ if(str[idx]=='('){ count++; } else { count--; if(count==0){ break; } } } } else { while(idx--){ if(str[idx]==')'){ count++; } else { count--; if(count==0){ break; } } } } //// output cout << idx+1 << endl; return 0; }