結果

問題 No.22 括弧の対応
ユーザー muuyuummuuyuum
提出日時 2016-07-09 16:38:42
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-04-21 10:44:11
合計ジャッジ時間 1,107 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,144 KB
testcase_01 AC 10 ms
6,272 KB
testcase_02 AC 9 ms
6,272 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 9 ms
6,016 KB
testcase_18 AC 9 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, raw_input().split())
s = raw_input()
cnt = 0
if s[K-1] == ")":
    s = s[:K]
    for i in reversed(xrange(len(s))):
        if s[i] == ")":
            cnt += 1
        if s[i] == "(":
            cnt -= 1
        if cnt == 0:
            print i+1
else:
    s = s[K-1:]
    for i in xrange(len(s)):
        if s[i] == "(":
            cnt += 1
        if s[i] == ")":
            cnt -= 1
        if cnt == 0:
            print i + K
0