結果
| 問題 | 
                            No.193 筒の数式
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-12-10 13:37:03 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 30 ms / 1,000 ms | 
| コード長 | 934 bytes | 
| コンパイル時間 | 105 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-09-16 15:49:24 | 
| 合計ジャッジ時間 | 1,519 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 | 
ソースコード
S = input()
ans_l = []
def f(st):
    flg = 1
    num = ""
    ans = 0
    for i in range(len(st)):
        if st[i] == "+":
            if flg == 1:
                ans += int(num)
                num = ""
            else:
                ans -= int(num)
                num = ""
            flg = 1
            continue
        if st[i] == "-":
            if flg == 1:
                ans += int(num)
                num = ""
            else:
                ans -= int(num)
                num = ""
            flg = 0
            continue
        num += st[i]
    if flg == 1:
        ans += int(num)
    else:
        ans -= int(num)
    return ans
        
for i in range(len(S)):
    newS = S[i:] + S[:i]
    if newS[0] == "+" or newS[0] == "-":
        continue
    if newS[-1] == "+" or newS[-1] == "-":
        continue
    if "+-" in newS or "-+" in newS:
        continue
    ans_l.append(f(newS))
print(max(ans_l))