結果

問題 No.22 括弧の対応
ユーザー jamadjamad
提出日時 2017-06-16 03:22:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 199 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 11,640 KB
実行使用メモリ 10,588 KB
最終ジャッジ日時 2023-10-25 08:13:53
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 29 ms
10,020 KB
testcase_02 AC 30 ms
10,020 KB
testcase_03 AC 33 ms
10,588 KB
testcase_04 AC 31 ms
10,264 KB
testcase_05 AC 30 ms
10,248 KB
testcase_06 AC 31 ms
10,492 KB
testcase_07 RE -
testcase_08 AC 31 ms
10,484 KB
testcase_09 RE -
testcase_10 AC 32 ms
10,504 KB
testcase_11 AC 31 ms
10,244 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 32 ms
10,560 KB
testcase_16 AC 33 ms
10,564 KB
testcase_17 AC 29 ms
10,020 KB
testcase_18 AC 30 ms
10,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
S=list(input())
ANS={}
queue=[]
for i in range(N):
    if S[i]==')':
        idx=queue.pop()
        ANS[idx]=i+1
    else:# =='('
        queue.append(i+1)
print(ANS[K])
0