結果

問題 No.22 括弧の対応
ユーザー akitsugu777
提出日時 2019-10-16 13:55:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 262 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-12 03:56:44
合計ジャッジ時間 1,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
S = input()

L = []
x = 1
for s in S:
    if s == '(':
        L += [x]
        x += 1
    else:
        x -= 1
        L += [x]

if S[K-1] == ')':
    print(L[:K-1].index(L[K-1]) + 1)
else:
    print(K + L[K:].index(L[K-1]) + 1)
0