結果

問題 No.22 括弧の対応
ユーザー ch1channnch1channn
提出日時 2022-12-12 11:28:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 437 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 61,440 KB
最終ジャッジ日時 2024-04-24 03:06:37
合計ジャッジ時間 1,828 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,504 KB
testcase_01 AC 39 ms
53,504 KB
testcase_02 AC 40 ms
54,144 KB
testcase_03 AC 46 ms
61,440 KB
testcase_04 AC 47 ms
60,160 KB
testcase_05 AC 43 ms
59,520 KB
testcase_06 AC 44 ms
60,800 KB
testcase_07 AC 46 ms
61,056 KB
testcase_08 AC 42 ms
53,760 KB
testcase_09 AC 45 ms
60,672 KB
testcase_10 AC 39 ms
53,760 KB
testcase_11 AC 44 ms
60,032 KB
testcase_12 AC 45 ms
61,184 KB
testcase_13 AC 44 ms
60,928 KB
testcase_14 AC 44 ms
60,032 KB
testcase_15 AC 45 ms
60,288 KB
testcase_16 AC 44 ms
60,800 KB
testcase_17 AC 38 ms
53,888 KB
testcase_18 AC 38 ms
53,760 KB
権限があれば一括ダウンロードができます

ソースコード

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