結果

問題 No.22 括弧の対応
ユーザー qibqib
提出日時 2023-02-24 23:33:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 225 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 76,380 KB
最終ジャッジ日時 2023-10-11 07:00:12
合計ジャッジ時間 3,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,348 KB
testcase_01 AC 73 ms
71,244 KB
testcase_02 AC 74 ms
71,504 KB
testcase_03 AC 84 ms
76,136 KB
testcase_04 AC 79 ms
76,116 KB
testcase_05 AC 80 ms
76,280 KB
testcase_06 AC 81 ms
76,164 KB
testcase_07 AC 80 ms
76,136 KB
testcase_08 AC 79 ms
76,380 KB
testcase_09 AC 80 ms
75,952 KB
testcase_10 AC 80 ms
76,332 KB
testcase_11 AC 78 ms
76,284 KB
testcase_12 AC 78 ms
76,288 KB
testcase_13 AC 78 ms
76,204 KB
testcase_14 AC 77 ms
75,788 KB
testcase_15 AC 79 ms
75,996 KB
testcase_16 AC 80 ms
76,208 KB
testcase_17 AC 73 ms
71,336 KB
testcase_18 AC 73 ms
71,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
s = input()

ans = [None for _ in range(n)]
q = []
for i in range(n):
  if s[i] == "(":
    q.append(i)
  elif s[i] == ")":
    j = q.pop()
    ans[j] = i
    ans[i] = j

print(ans[k - 1] + 1)
0