結果

問題 No.22 括弧の対応
ユーザー convexineq
提出日時 2020-11-25 06:34:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 309 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 60,856 KB
最終ジャッジ日時 2024-07-23 19:12:05
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

print(ans)
0