結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-06 12:23:24 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 492 bytes |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 7,072 KB |
| 実行使用メモリ | 42,072 KB |
| 最終ジャッジ日時 | 2024-10-13 00:54:13 |
| 合計ジャッジ時間 | 2,800 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 9 |
ソースコード
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let [N, K, S] = input.split(/\s/);
K = Number(K);
S = S.replace(/\s/, '');
for (let i in S) {
i = Number(i);
if (S.match(/\([\s]*\)/)) {
let M = S.match(/\([\s]*\)/);
if (M.index == K - 1) {
console.log(M.index + M[0].length);
break;
} else if (M.index + M[0].length == K - 1) {
console.log(M.index);
break;
}
S = S.replace(/\([\s]*\)/, Array(M[0].length).fill(' ').join ``);
}
}