結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
Elk
|
| 提出日時 | 2018-07-01 23:59:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 1,489 ms |
| コンパイル使用メモリ | 167,564 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 01:25:13 |
| 合計ジャッジ時間 | 2,313 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, K, i, cnt = 0, flag = 0, left = 0, right = 0;
string str;
cin >> N >> K >> str;
for(i = 0; i < str.size(); i++){
if(str[i] == '('){
cnt++;
}else{
cnt--;
}
if(str[K - 1] == '('){
if(i > K - 1){
if(cnt == K - 1){
cout << i + 1 << endl;
}
}
}else{
if(cnt == N - K){
cout << N - i << endl;
}
}
}
return 0;
}
Elk