結果

問題 No.193 筒の数式
コンテスト
ユーザー tnoda_
提出日時 2015-08-19 21:01:49
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 457 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 117 ms
コンパイル使用メモリ 77,472 KB
最終ジャッジ日時 2025-12-03 16:19:58
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from re import findall

def calc(s):
    ts = findall('\+|\-|\d+', s)
    if ts[0] == '+' or ts[0] == '-':
        return None
    acc = int(ts[0])
    ts = ts[1:]
    while ts:
        if len(ts) == 1:
            return None
        if ts[0] == '+':
            acc += int(ts[1])
        else:
            acc -= int(ts[1])
        ts = ts[2:]
    return acc

S = raw_input()
ss = [(S+S)[i:i+len(S)] for i in range(len(S))]
print(max(calc(s) for s in ss))
0