結果

問題 No.22 括弧の対応
ユーザー otsunekootsuneko
提出日時 2021-05-14 15:53:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 315 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 61,988 KB
最終ジャッジ日時 2024-04-09 20:09:38
合計ジャッジ時間 1,606 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
54,136 KB
testcase_01 AC 40 ms
53,808 KB
testcase_02 AC 38 ms
54,052 KB
testcase_03 AC 42 ms
61,988 KB
testcase_04 AC 40 ms
60,320 KB
testcase_05 AC 40 ms
60,316 KB
testcase_06 AC 41 ms
61,316 KB
testcase_07 AC 41 ms
61,512 KB
testcase_08 AC 37 ms
54,008 KB
testcase_09 AC 41 ms
61,968 KB
testcase_10 AC 37 ms
53,608 KB
testcase_11 AC 41 ms
60,068 KB
testcase_12 AC 43 ms
60,980 KB
testcase_13 AC 42 ms
61,820 KB
testcase_14 AC 38 ms
53,932 KB
testcase_15 AC 42 ms
60,948 KB
testcase_16 AC 42 ms
61,120 KB
testcase_17 AC 36 ms
53,972 KB
testcase_18 AC 38 ms
54,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

d = deque()
for i in range(N):
    if S[i] == "(":
        d.append(i+1)
    else:
        n = d.pop()
        if K == i+1:
            print(n)
            break
        elif K == n:
            print(i+1)
            break
0