結果

問題 No.193 筒の数式
ユーザー mlihua09mlihua09
提出日時 2020-09-04 01:03:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 1,000 ms
コード長 621 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 53,812 KB
最終ジャッジ日時 2024-05-03 10:15:50
合計ジャッジ時間 1,690 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,652 KB
testcase_01 AC 35 ms
52,196 KB
testcase_02 AC 34 ms
52,360 KB
testcase_03 AC 38 ms
52,256 KB
testcase_04 AC 38 ms
53,076 KB
testcase_05 AC 35 ms
53,236 KB
testcase_06 AC 37 ms
52,688 KB
testcase_07 AC 38 ms
52,620 KB
testcase_08 AC 36 ms
52,440 KB
testcase_09 AC 35 ms
52,964 KB
testcase_10 AC 38 ms
52,740 KB
testcase_11 AC 35 ms
53,284 KB
testcase_12 AC 36 ms
52,764 KB
testcase_13 AC 35 ms
52,536 KB
testcase_14 AC 34 ms
52,340 KB
testcase_15 AC 36 ms
52,588 KB
testcase_16 AC 36 ms
52,340 KB
testcase_17 AC 35 ms
53,812 KB
testcase_18 AC 36 ms
52,832 KB
権限があれば一括ダウンロードができます

ソースコード

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