結果

問題 No.22 括弧の対応
ユーザー AtamaokaCAtamaokaC
提出日時 2021-06-19 17:54:30
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 354 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,392 KB
最終ジャッジ日時 2023-09-05 01:05:29
合計ジャッジ時間 2,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,448 KB
testcase_01 AC 71 ms
71,172 KB
testcase_02 AC 72 ms
71,156 KB
testcase_03 AC 72 ms
71,436 KB
testcase_04 AC 72 ms
71,600 KB
testcase_05 AC 71 ms
71,428 KB
testcase_06 AC 72 ms
71,260 KB
testcase_07 AC 73 ms
76,124 KB
testcase_08 AC 72 ms
71,472 KB
testcase_09 AC 75 ms
76,392 KB
testcase_10 AC 71 ms
71,552 KB
testcase_11 AC 72 ms
71,580 KB
testcase_12 AC 75 ms
76,136 KB
testcase_13 AC 74 ms
76,332 KB
testcase_14 AC 71 ms
71,328 KB
testcase_15 AC 72 ms
71,172 KB
testcase_16 AC 72 ms
71,396 KB
testcase_17 AC 71 ms
71,124 KB
testcase_18 AC 70 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inpl = lambda: list(map(int,input().split()))
N, K = inpl()
S = input()
if S[K-1] == '(':
    i = K-1
else:
    i = 0
pool = [i]
for j in range(i+1,N):
    if S[j] == '(':
        pool.append(j)
    else:
        p = pool.pop()
        if j == K-1:
            print(p+1)
            break
        elif p == K-1:
            print(j+1)
            break
0