結果

問題 No.22 括弧の対応
ユーザー lloyzlloyz
提出日時 2022-08-10 14:38:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 10,076 KB
最終ジャッジ日時 2023-10-21 00:43:31
合計ジャッジ時間 1,757 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,048 KB
testcase_01 AC 25 ms
10,048 KB
testcase_02 AC 25 ms
10,048 KB
testcase_03 AC 25 ms
10,076 KB
testcase_04 AC 28 ms
10,056 KB
testcase_05 AC 31 ms
10,052 KB
testcase_06 AC 30 ms
10,060 KB
testcase_07 AC 26 ms
10,072 KB
testcase_08 AC 25 ms
10,060 KB
testcase_09 AC 26 ms
10,056 KB
testcase_10 AC 26 ms
10,064 KB
testcase_11 AC 25 ms
10,052 KB
testcase_12 AC 26 ms
10,060 KB
testcase_13 AC 27 ms
10,064 KB
testcase_14 AC 26 ms
10,048 KB
testcase_15 AC 26 ms
10,076 KB
testcase_16 AC 31 ms
10,076 KB
testcase_17 AC 25 ms
10,048 KB
testcase_18 AC 25 ms
10,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n, k = map(int, input().split())
S = input()

Que = deque()
for i in range(n):
    if S[i] == '(':
        Que.append(i)
    else:
        f = Que.pop()
        if i + 1 == k:
            print(f + 1)
            break
        elif f + 1 == k:
            print(i + 1)
            break
0