結果

問題 No.22 括弧の対応
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-14 21:13:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 466 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 78,508 KB
最終ジャッジ日時 2023-09-05 06:57:53
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
72,984 KB
testcase_01 AC 109 ms
72,884 KB
testcase_02 AC 108 ms
72,696 KB
testcase_03 AC 116 ms
78,508 KB
testcase_04 AC 112 ms
78,080 KB
testcase_05 AC 113 ms
77,720 KB
testcase_06 AC 114 ms
77,956 KB
testcase_07 AC 113 ms
78,092 KB
testcase_08 AC 111 ms
78,160 KB
testcase_09 AC 111 ms
77,984 KB
testcase_10 AC 110 ms
77,992 KB
testcase_11 AC 111 ms
77,964 KB
testcase_12 AC 115 ms
77,964 KB
testcase_13 AC 116 ms
78,108 KB
testcase_14 AC 112 ms
77,572 KB
testcase_15 AC 111 ms
78,212 KB
testcase_16 AC 113 ms
78,100 KB
testcase_17 AC 107 ms
72,984 KB
testcase_18 AC 110 ms
73,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,K = map(int,input().split())
S = list(input())[:-1]
L = deque()
R = deque()
Y = defaultdict(lambda:-1)
for i,s in enumerate(S):
    
    if s==')':
        j = L.pop()
        Y[j]=i
        Y[i]=j
    else:
        L.append(i)
        
print(Y[K-1]+1)
    
    
0