結果

問題 No.1961 Clear Brackets
ユーザー 👑 rin204rin204
提出日時 2022-05-27 22:16:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 75,596 KB
最終ジャッジ日時 2023-10-20 20:23:11
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,520 KB
testcase_01 AC 38 ms
53,520 KB
testcase_02 AC 38 ms
53,520 KB
testcase_03 AC 38 ms
53,520 KB
testcase_04 WA -
testcase_05 AC 39 ms
53,520 KB
testcase_06 AC 38 ms
53,520 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 38 ms
53,520 KB
testcase_10 AC 38 ms
53,520 KB
testcase_11 AC 38 ms
53,520 KB
testcase_12 WA -
testcase_13 AC 38 ms
53,520 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 43 ms
59,908 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 47 ms
62,092 KB
testcase_28 WA -
testcase_29 AC 60 ms
75,524 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 47 ms
62,092 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 62 ms
75,560 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input().strip()

ans = 0
mi = 0
tot = 0
flg = False
flg2 = False
for s in S:
    if s == "(":
        tot += 1
        flg = True
    elif s == ")":
        tot -= 1
        flg2 = True
        if tot < mi:
            mi = tot
            if flg:
                ans += 1
                flg = False
                flg2 = False
    else:
        if flg:
            tot -= 1
            flg2 = True
            if tot < mi:
                mi = tot
                if flg:
                    ans += 1
                    flg = False
                    flg2 = False
        else:
            tot += 1
            flg = True
ans += flg2
print(ans)
0