結果

問題 No.22 括弧の対応
ユーザー zimphazimpha
提出日時 2017-12-09 02:15:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 234 bytes
コンパイル時間 1,121 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 76,284 KB
最終ジャッジ日時 2023-09-27 13:21:43
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,296 KB
testcase_01 AC 65 ms
71,268 KB
testcase_02 AC 67 ms
71,336 KB
testcase_03 AC 75 ms
76,252 KB
testcase_04 AC 76 ms
76,164 KB
testcase_05 AC 71 ms
76,112 KB
testcase_06 AC 71 ms
76,060 KB
testcase_07 AC 72 ms
76,248 KB
testcase_08 AC 69 ms
76,208 KB
testcase_09 AC 71 ms
76,284 KB
testcase_10 AC 72 ms
75,960 KB
testcase_11 AC 73 ms
76,072 KB
testcase_12 AC 71 ms
76,184 KB
testcase_13 AC 69 ms
76,168 KB
testcase_14 AC 68 ms
75,864 KB
testcase_15 AC 71 ms
76,188 KB
testcase_16 AC 70 ms
76,128 KB
testcase_17 AC 69 ms
71,268 KB
testcase_18 AC 67 ms
71,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = list(map(int, input().split()))
s = input()
stack = []
mate = [0] * n
for i, c in enumerate(s):
  if c == '(':
    stack.append(i)
  else:
    mate[stack[-1]] = i
    mate[i] = stack[-1]
    stack.pop(-1)
print(mate[k - 1] + 1)
0