結果

問題 No.193 筒の数式
コンテスト
ユーザー lloyz
提出日時 2023-04-27 00:06:42
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 26 ms / 1,000 ms
+ 250µs
コード長 648 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 76 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2026-10-14 20:23:16
合計ジャッジ時間 2,129 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = list(input())

n = len(S)
ans = -10**18
for i in range(n):
    T = S[i:] + S[:i]
    t = ''.join(T)
    res = 0
    flag = True
    num = '0'
    if t[0] in ['+', '-'] or t[-1] in ['+', '-']:
        continue
    t = '+' + t
    for tt in t:
        if tt == '-' or tt == '+':
            if flag:
                res += int(num)
            else:
                res -= int(num)
            num = ''
            if tt == '+':
                flag = True
            else:
                flag = False
        else:
            num += tt
    if flag:
        res += int(num)
    else:
        res -= int(num)
    ans = max(ans, res)
print(ans)
0