結果

問題 No.22 括弧の対応
ユーザー nohakai3nohakai3
提出日時 2022-10-22 10:57:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 313 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 77,444 KB
最終ジャッジ日時 2023-09-14 06:34:27
合計ジャッジ時間 3,704 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,232 KB
testcase_01 AC 92 ms
71,476 KB
testcase_02 AC 91 ms
71,240 KB
testcase_03 AC 104 ms
77,444 KB
testcase_04 AC 101 ms
77,144 KB
testcase_05 AC 100 ms
77,136 KB
testcase_06 AC 102 ms
77,160 KB
testcase_07 AC 101 ms
77,176 KB
testcase_08 AC 98 ms
76,920 KB
testcase_09 AC 101 ms
77,224 KB
testcase_10 AC 98 ms
77,264 KB
testcase_11 AC 100 ms
76,876 KB
testcase_12 AC 102 ms
77,136 KB
testcase_13 AC 101 ms
77,256 KB
testcase_14 AC 101 ms
76,960 KB
testcase_15 AC 101 ms
77,280 KB
testcase_16 AC 101 ms
77,280 KB
testcase_17 AC 92 ms
71,376 KB
testcase_18 AC 91 ms
71,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
l=list(input())
from collections import deque
s=deque()
ans=[]
for i in range(n):
    if l[i]=="(":
        s.append(i)
    else:
        ans.append([i+1,s.pop()+1])

for x in ans:
    if x[0]==k:
        print(x[1])
        exit()
    elif x[1]==k:
        print(x[0])
        exit()
0