結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2018-02-16 22:43:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 611 ms |
コンパイル使用メモリ | 67,840 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 03:52:47 |
合計ジャッジ時間 | 1,342 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 10 |
ソースコード
#include<iostream> #include<cmath> using namespace std; int main(){ int N,K,count=0; char s[10001]; cin >> N >> K >> s; if(s[K+1]=='('){ for(int i=K;i<N;i++){ if(s[i]==')'){ if(count==0){ cout << i+1; return 0; } count--; } else{ count++; } } } else{ for(int i=K-2;i>=0;i--){ if(s[i]=='('){ if(count==0){ cout << i+1; return 0; } count--; } else{ count++; } } } return 0; }