結果

問題 No.22 括弧の対応
ユーザー convexineqconvexineq
提出日時 2020-11-25 06:31:04
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 86,360 KB
実行使用メモリ 76,096 KB
最終ジャッジ日時 2023-10-01 01:39:20
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,344 KB
testcase_01 AC 71 ms
71,376 KB
testcase_02 AC 71 ms
71,044 KB
testcase_03 AC 81 ms
75,884 KB
testcase_04 AC 76 ms
75,900 KB
testcase_05 AC 75 ms
75,956 KB
testcase_06 AC 77 ms
75,880 KB
testcase_07 AC 76 ms
76,040 KB
testcase_08 AC 71 ms
71,352 KB
testcase_09 AC 77 ms
75,984 KB
testcase_10 AC 70 ms
71,384 KB
testcase_11 AC 76 ms
75,688 KB
testcase_12 AC 75 ms
76,096 KB
testcase_13 AC 75 ms
75,968 KB
testcase_14 AC 70 ms
70,896 KB
testcase_15 AC 76 ms
75,784 KB
testcase_16 AC 76 ms
76,004 KB
testcase_17 AC 69 ms
71,048 KB
testcase_18 AC 70 ms
71,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
s = input()
st = []
for i,si in enumerate(s):
    i += 1
    if st and st[-1][0] == "(" and si == ")":
        if i == k:
            ans = st[-1][1]
            break
        elif st[-1][1] == k:
            ans = i
            break
        else:
            st.pop()
    else:
        st.append((si,i))

print(ans)
0