結果

問題 No.22 括弧の対応
ユーザー akihito0000
提出日時 2016-08-14 08:29:32
言語 Python2
(2.7.18)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-07-20 07:15:25
合計ジャッジ時間 883 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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