結果

問題 No.22 括弧の対応
ユーザー ch1channn
提出日時 2022-12-12 11:28:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 437 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 62,392 KB
最終ジャッジ日時 2024-11-06 09:53:53
合計ジャッジ時間 1,905 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
if sys.platform =='ios':
	import clipboard
	a=clipboard.get()
	a = a.split('\n')
	text = '\n'.join(a)
	with open('input_file.txt','w') as f:
		f.write(text)
	sys.stdin = open('input_file.txt')

from collections import deque
	
n,k = map(int,input().split())
s = input()
q = deque([])


for i,x in enumerate(s):
	if x == "(":
		q.append(i+1)
	else:
		y = q.pop()
		if i+1 == k:
			print(y)
		elif y == k:
			print(i+1)
			exit()
0