結果

問題 No.22 括弧の対応
ユーザー TksiTksi
提出日時 2018-11-06 16:29:17
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 299 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 42,388 KB
最終ジャッジ日時 2023-09-27 13:32:14
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
42,256 KB
testcase_01 AC 67 ms
42,256 KB
testcase_02 AC 65 ms
42,156 KB
testcase_03 AC 66 ms
42,188 KB
testcase_04 AC 67 ms
42,184 KB
testcase_05 AC 65 ms
42,216 KB
testcase_06 AC 71 ms
42,292 KB
testcase_07 AC 66 ms
42,188 KB
testcase_08 AC 66 ms
42,192 KB
testcase_09 AC 68 ms
42,200 KB
testcase_10 AC 69 ms
42,196 KB
testcase_11 AC 70 ms
42,320 KB
testcase_12 AC 68 ms
42,232 KB
testcase_13 AC 65 ms
42,384 KB
testcase_14 AC 66 ms
42,156 KB
testcase_15 AC 66 ms
42,388 KB
testcase_16 AC 66 ms
42,188 KB
testcase_17 AC 66 ms
42,324 KB
testcase_18 AC 67 ms
42,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let input = require('fs').readFileSync('/dev/stdin', 'utf8')
let [N, K, S] = input.split(/\s/);
K = Number(K);
S = S.replace('\n', '');
let a = str => str == '(' ? 1 : -1;
let t = c = a(S[K - 1])
let e = K - 1 + t;
for (;;) {
  c += a(S[e]);
  e += t;
  if (c == 0) break;
}
console.log(1 + e - t);
0