結果

問題 No.22 括弧の対応
ユーザー 👑 colognecologne
提出日時 2022-01-22 13:34:09
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 75,844 KB
最終ジャッジ日時 2023-08-18 06:34:02
合計ジャッジ時間 3,327 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,132 KB
testcase_01 AC 74 ms
71,176 KB
testcase_02 AC 71 ms
71,584 KB
testcase_03 AC 77 ms
75,792 KB
testcase_04 AC 76 ms
75,608 KB
testcase_05 AC 75 ms
75,776 KB
testcase_06 AC 79 ms
75,844 KB
testcase_07 AC 76 ms
75,744 KB
testcase_08 AC 71 ms
71,576 KB
testcase_09 AC 80 ms
75,808 KB
testcase_10 AC 71 ms
71,508 KB
testcase_11 AC 79 ms
75,772 KB
testcase_12 AC 78 ms
75,736 KB
testcase_13 AC 78 ms
75,668 KB
testcase_14 AC 75 ms
71,124 KB
testcase_15 AC 79 ms
75,844 KB
testcase_16 AC 78 ms
75,480 KB
testcase_17 AC 74 ms
71,372 KB
testcase_18 AC 73 ms
71,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    S = []
    for i, s in enumerate(input().rstrip()):
        if s == '(':
            S.append(i)
        else:
            a = S.pop()
            if 1+a == K or 1+i == K:
                print(a+i+2-K)
                return


if __name__ == '__main__':
    main()
0