結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2016-04-19 09:51:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 542 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 64,976 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 14:02:52 |
合計ジャッジ時間 | 1,365 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 15 |
ソースコード
#include <iostream> using namespace std; int main(){ int n,k,count = 0; string s; cin >> n >> k >> s; if(s[k - 1] == '('){ for(int i = k - 1;i < n;i++){ if(s[i] == ')'){ if(count-- == 0){ cout << i << endl; return 0; } }else count++; } }else{ for(int i = k - 1;i--;){ if(s[i] == '('){ if(count-- == 0){ cout << i << endl; return 0; }else count++; } } } }