結果

問題 No.22 括弧の対応
ユーザー ohanaohana
提出日時 2023-09-29 16:25:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 1,335 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 76,276 KB
最終ジャッジ日時 2023-09-29 16:25:14
合計ジャッジ時間 3,010 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,360 KB
testcase_01 AC 69 ms
71,232 KB
testcase_02 AC 68 ms
71,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 75 ms
75,820 KB
testcase_08 WA -
testcase_09 AC 74 ms
76,276 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 72 ms
76,236 KB
testcase_13 AC 75 ms
76,164 KB
testcase_14 AC 70 ms
71,244 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i, c in enumerate(s):
    i += 1
    if i == k:
        if c == ")":
            print(stk[-1])
            break
        else:
            stk.append("*")
    if c == "(":
        stk.append(i)
    else:
        if stk.pop() == "*":
            print(i - 1)
            break
0