結果

問題 No.193 筒の数式
ユーザー ohanaohana
提出日時 2023-11-24 10:01:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 428 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-09-26 08:32:54
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()


def calc(s: str):
    if s[0] in {"+", "-"} or s[-1] in {"+", "-"}:
        return -float("INF")
    else:
        res = 0
        for c in s.split("+"):
            if "-" in c:
                a, *b = c.split("-")
                c = int(a) - sum(map(int, b))
            res += int(c)
        return res


ans = -float("INF")
for i in range(len(s)):
    ans = max(ans, calc(s))
    s = s[1:] + s[0]

print(ans)
0