結果

問題 No.22 括弧の対応
ユーザー irisAshirisAsh
提出日時 2017-08-12 00:02:53
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 32 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 44,176 KB
最終ジャッジ日時 2023-09-27 13:18:14
合計ジャッジ時間 3,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
44,172 KB
testcase_01 AC 77 ms
42,248 KB
testcase_02 AC 79 ms
42,016 KB
testcase_03 AC 79 ms
42,420 KB
testcase_04 AC 79 ms
42,352 KB
testcase_05 AC 80 ms
42,228 KB
testcase_06 AC 80 ms
42,352 KB
testcase_07 AC 79 ms
42,176 KB
testcase_08 AC 80 ms
42,140 KB
testcase_09 AC 80 ms
42,140 KB
testcase_10 AC 79 ms
42,164 KB
testcase_11 AC 78 ms
42,196 KB
testcase_12 AC 80 ms
42,236 KB
testcase_13 AC 83 ms
42,300 KB
testcase_14 AC 78 ms
42,004 KB
testcase_15 AC 78 ms
42,388 KB
testcase_16 AC 82 ms
42,212 KB
testcase_17 AC 78 ms
42,160 KB
testcase_18 AC 79 ms
44,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let i = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n').slice(0, -1)
let n = i[0].split(' ')
let s = i[1].split('')
let t = []
for (let c = 0; c < s.length; c++) {
  if (s[c] === '(') t.push(c)
  else {
    let x = t.pop()
    if (x+1 == n[1]) {
      console.log(c+1)
      break
    } else if (c+1 == n[1]) {
      console.log(x+1)
      break
    }
  }
}
0