結果

問題 No.22 括弧の対応
ユーザー HIROPON87069639HIROPON87069639
提出日時 2016-02-27 18:58:40
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 357 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 6,424 KB
最終ジャッジ日時 2023-09-27 13:02:05
合計ジャッジ時間 1,081 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,964 KB
testcase_01 AC 11 ms
6,048 KB
testcase_02 AC 10 ms
5,916 KB
testcase_03 AC 11 ms
6,304 KB
testcase_04 AC 9 ms
6,144 KB
testcase_05 AC 10 ms
6,060 KB
testcase_06 AC 10 ms
6,224 KB
testcase_07 AC 10 ms
6,236 KB
testcase_08 AC 9 ms
6,180 KB
testcase_09 AC 11 ms
6,196 KB
testcase_10 AC 10 ms
6,204 KB
testcase_11 AC 10 ms
6,232 KB
testcase_12 AC 11 ms
6,044 KB
testcase_13 AC 12 ms
6,148 KB
testcase_14 AC 10 ms
5,944 KB
testcase_15 AC 10 ms
6,324 KB
testcase_16 AC 11 ms
6,424 KB
testcase_17 AC 10 ms
5,848 KB
testcase_18 AC 10 ms
6,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())
S = raw_input()
Slist = list(S)
left = []
for i in range(0, N):
    if Slist[i] == "(":
        left.append(i)
    elif Slist[i] == ")":
        tmp = left.pop()
        if i == K-1:
            print tmp + 1
            exit()
        elif tmp == K-1:
            print i + 1
            exit()
0