結果

問題 No.22 括弧の対応
ユーザー akitsugu777akitsugu777
提出日時 2019-10-16 13:55:23
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 262 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 10,560 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-09-02 21:41:31
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,824 KB
testcase_01 AC 17 ms
7,796 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 18 ms
8,296 KB
testcase_04 AC 17 ms
7,964 KB
testcase_05 AC 17 ms
7,864 KB
testcase_06 AC 17 ms
8,272 KB
testcase_07 WA -
testcase_08 AC 18 ms
8,172 KB
testcase_09 WA -
testcase_10 AC 17 ms
8,336 KB
testcase_11 AC 17 ms
7,820 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 18 ms
8,140 KB
testcase_16 AC 19 ms
8,212 KB
testcase_17 AC 16 ms
7,816 KB
testcase_18 AC 17 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

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