結果

問題 No.22 括弧の対応
ユーザー aqua_tenhouaqua_tenhou
提出日時 2021-07-13 21:21:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 308 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 77,668 KB
最終ジャッジ日時 2023-09-15 13:37:56
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,880 KB
testcase_01 AC 93 ms
71,668 KB
testcase_02 AC 95 ms
71,964 KB
testcase_03 AC 99 ms
77,556 KB
testcase_04 AC 99 ms
77,472 KB
testcase_05 AC 98 ms
77,160 KB
testcase_06 AC 100 ms
77,592 KB
testcase_07 AC 99 ms
77,480 KB
testcase_08 AC 94 ms
71,676 KB
testcase_09 AC 98 ms
77,344 KB
testcase_10 AC 92 ms
71,784 KB
testcase_11 AC 96 ms
77,240 KB
testcase_12 AC 99 ms
77,484 KB
testcase_13 AC 99 ms
77,456 KB
testcase_14 AC 97 ms
76,888 KB
testcase_15 AC 97 ms
77,668 KB
testcase_16 AC 99 ms
77,464 KB
testcase_17 AC 93 ms
71,624 KB
testcase_18 AC 93 ms
71,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,k = map(int,input().split())
s = list(input())
q = deque([])

for i,x in enumerate(s):
    if x == "(":
        q.append(i+1)
    else:
        y = q.pop()
        if i+1 == k:
            print(y)
        elif y == k:
            print(i+1)
            exit()
            

0