結果

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

ソースコード

diff #


S = input()
N = len(S)
ans = -10 ** 10
for i in range(N):
    x = 1
    y = ''
    a = 0
    for j in range(i + 1 - N, i + 1):
        if S[j] == '+':
            if y:
                a += x * int(y)
                x = 1
                y = ''
            else:
                a = -10**10
                break
        elif S[j] == '-':
            if y:
                a += x * int(y)
                x = -1
                y = ''
            else:
                a = -10**10
                break
        else:
            y += S[j]
    if y:
        a += x * int(y)
        ans = max(ans, a)
        
print(ans)
0