結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2019-04-24 17:37:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 269 bytes |
コンパイル時間 | 442 ms |
コンパイル使用メモリ | 54,876 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:41:51 |
合計ジャッジ時間 | 1,183 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <string> using namespace std; int main() { int N, K, cnt = 0; string S; cin >> N >> K >> S; char c = S[--K]; while (cnt >= 0) K += c == '(' ? 1 : -1, cnt += S[K] == c ? 1 : -1; cout << K + 1 << endl; return 0; }