結果

問題 No.22 括弧の対応
ユーザー akihito0000akihito0000
提出日時 2016-08-14 08:30:48
言語 Python2
(2.7.18)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 396 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-09-27 13:07:36
合計ジャッジ時間 1,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,864 KB
testcase_01 AC 11 ms
5,980 KB
testcase_02 AC 10 ms
5,964 KB
testcase_03 AC 12 ms
6,284 KB
testcase_04 AC 11 ms
6,096 KB
testcase_05 AC 12 ms
6,048 KB
testcase_06 AC 14 ms
6,216 KB
testcase_07 AC 13 ms
6,000 KB
testcase_08 AC 10 ms
5,964 KB
testcase_09 AC 13 ms
6,292 KB
testcase_10 AC 10 ms
5,940 KB
testcase_11 AC 11 ms
5,992 KB
testcase_12 AC 11 ms
6,216 KB
testcase_13 AC 14 ms
6,548 KB
testcase_14 AC 10 ms
5,940 KB
testcase_15 AC 12 ms
6,144 KB
testcase_16 AC 12 ms
6,144 KB
testcase_17 AC 10 ms
5,960 KB
testcase_18 AC 11 ms
6,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-

### INPUT ###
N , h = map(int, raw_input().split())
arrays = raw_input()
num = []
ans = {}
for i,array in enumerate(arrays):
       	if array == "(":
       		num.append(i+1)
       	elif array == ")":
       		tmp = num.pop(-1)
       		ans.update({i+1 : tmp})
       		ans.update({tmp : i+1})
       	if h in ans:
       		print ans[h]
       		exit()
0