結果

問題 No.22 括弧の対応
ユーザー kanoekakihitokanoekakihito
提出日時 2016-09-14 22:21:48
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 209 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-09-27 13:08:14
合計ジャッジ時間 1,242 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,720 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 15 ms
7,768 KB
testcase_03 AC 22 ms
8,536 KB
testcase_04 AC 16 ms
8,264 KB
testcase_05 AC 15 ms
8,244 KB
testcase_06 AC 19 ms
8,264 KB
testcase_07 AC 16 ms
8,488 KB
testcase_08 AC 15 ms
8,224 KB
testcase_09 AC 16 ms
8,228 KB
testcase_10 AC 15 ms
8,384 KB
testcase_11 AC 15 ms
8,208 KB
testcase_12 AC 17 ms
8,264 KB
testcase_13 AC 22 ms
8,512 KB
testcase_14 AC 15 ms
7,784 KB
testcase_15 AC 19 ms
8,496 KB
testcase_16 AC 20 ms
8,540 KB
testcase_17 AC 14 ms
7,896 KB
testcase_18 AC 15 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split(" "))
k -= 1
b = input()
s = [i for i in range(n)]
while True:
	i = b.index("()")
	p = [s.pop(i), s.pop(i)]
	b = b.replace("()", "", 1)
	if k in p:
		print(sum(p) - k + 1)
		break
0