結果

問題 No.193 筒の数式
ユーザー rlangevinrlangevin
提出日時 2023-01-08 23:45:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 1,000 ms
コード長 677 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 71,608 KB
最終ジャッジ日時 2023-08-22 08:06:46
合計ジャッジ時間 2,988 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,292 KB
testcase_01 AC 72 ms
71,172 KB
testcase_02 AC 71 ms
71,608 KB
testcase_03 AC 72 ms
71,372 KB
testcase_04 AC 71 ms
71,544 KB
testcase_05 AC 71 ms
71,440 KB
testcase_06 AC 73 ms
71,444 KB
testcase_07 AC 73 ms
71,472 KB
testcase_08 AC 71 ms
71,500 KB
testcase_09 AC 72 ms
71,316 KB
testcase_10 AC 73 ms
71,416 KB
testcase_11 AC 72 ms
71,304 KB
testcase_12 AC 72 ms
71,412 KB
testcase_13 AC 71 ms
71,296 KB
testcase_14 AC 72 ms
71,400 KB
testcase_15 AC 73 ms
71,588 KB
testcase_16 AC 72 ms
71,388 KB
testcase_17 AC 73 ms
71,556 KB
testcase_18 AC 72 ms
71,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
N = len(S)
ans = -10 ** 18


for i in range(N):
    T = S[i:] + S[:i]
    T = "".join(T)
    num = 0
    flag = 1
    val = 0
    if T[0] == "+" or T[0] == "-":
        continue
    if T[-1] == "+" or T[-1] == "-":
        continue
    T = "+" + T
    for t in T:
        if t == "-" or t == "+":
            if flag:
                val += int(num)
            else:
                val -= int(num)
            num = ""
            if t == "-":
                flag = 0
            else:
                flag = 1
        else:
            num += t
    if flag:
        val += int(num)
    else:
        val -= int(num)
    ans = max(ans, val)
    
print(ans)
0