結果

問題 No.22 括弧の対応
ユーザー Snark86Snark86
提出日時 2016-04-23 04:38:04
言語 Python2
(2.7.18)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 6,668 KB
実行使用メモリ 6,064 KB
最終ジャッジ日時 2023-09-27 13:03:56
合計ジャッジ時間 1,024 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,972 KB
testcase_01 AC 10 ms
5,888 KB
testcase_02 AC 9 ms
5,988 KB
testcase_03 AC 9 ms
5,932 KB
testcase_04 AC 10 ms
5,952 KB
testcase_05 AC 10 ms
5,876 KB
testcase_06 AC 10 ms
5,908 KB
testcase_07 AC 10 ms
5,864 KB
testcase_08 AC 9 ms
5,888 KB
testcase_09 AC 9 ms
5,864 KB
testcase_10 AC 9 ms
5,948 KB
testcase_11 AC 9 ms
5,876 KB
testcase_12 AC 9 ms
5,888 KB
testcase_13 AC 9 ms
5,804 KB
testcase_14 AC 9 ms
6,056 KB
testcase_15 AC 10 ms
5,844 KB
testcase_16 AC 9 ms
6,064 KB
testcase_17 AC 10 ms
5,972 KB
testcase_18 AC 9 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int,raw_input().split())
line = raw_input()

if line[k-1] == "(":
	a = 1
else:
	a = -1
	
b = 0
c = 0
while True:
	b += a
	if line[k+b-1] != line[k-1]:
		if c == 0:
			ans = k+b
			break
		else:
			c -= 1
	else:
		c += 1
print ans
0