結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2016-05-09 15:06:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 418 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 63,616 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:12:37 |
合計ジャッジ時間 | 1,393 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include<iostream> using namespace std; char clist[10010]; int main(){ int N,K; cin>>N>>K; cin>>clist; K--; int cnt=1; if(clist[K] == ')'){ K--; while(cnt != 0){ if(clist[K] == ')') cnt++; else cnt--; K--; } cout<<K+2<<endl; }else{ K++; while(cnt != 0){ if(clist[K] == '(') cnt++; else cnt--; K++; } cout<<K<<endl; } return 0; }