結果

問題 No.193 筒の数式
ユーザー titiatitia
提出日時 2022-06-19 02:35:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 686 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-19 04:13:22
合計ジャッジ時間 1,553 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 33 ms
10,880 KB
testcase_06 AC 32 ms
10,752 KB
testcase_07 AC 39 ms
10,752 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 AC 33 ms
10,752 KB
testcase_11 AC 33 ms
10,752 KB
testcase_12 AC 32 ms
10,752 KB
testcase_13 AC 33 ms
10,752 KB
testcase_14 AC 31 ms
10,880 KB
testcase_15 AC 33 ms
10,752 KB
testcase_16 AC 34 ms
10,752 KB
testcase_17 AC 34 ms
10,880 KB
testcase_18 AC 34 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(S):
    ANS=0

    X=["+"]
    while S:
        if S[0]=="+" or S[0]=="-":
            X.append(S[0])
            S=S[1:]
            continue
        for i in range(len(S)):
            if S[i]=="+" or S[i]=="-":
                X.append(int(S[:i]))
                S=S[i:]
                break
        else:
            X.append(int(S))
            break

    for i in range(len(X)):
        if X[i]=="+":
            ANS+=X[i+1]
        elif X[i]=="-":
            ANS-=X[i+1]
    return ANS

S=input()
MAX=-1<<60
for i in range(len(S)):
    #print(S)

    if S[0] in "+-" or S[-1] in "+-":
        True
    else:
        MAX=max(MAX,calc(S))

    S=S[1:]+S[0]

print(MAX)
0