結果

問題 No.193 筒の数式
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-01 19:16:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,976 KB
実行使用メモリ 10,084 KB
最終ジャッジ日時 2023-10-24 19:20:30
合計ジャッジ時間 1,389 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools


INF = 2 ** 31 - 2


def solve(s):
    answer = -INF
    length = len(s)
    f = lambda c: c in "+-"
    for i in range(length):
        to_eval = ""
        for key, group in itertools.groupby((s * 2)[i: i + length], f):
            if key:
                to_eval += "".join(group)
            else:
                to_eval += "".join(group).lstrip("0")
        if to_eval.startswith(('+', '-')) or to_eval.endswith(('+', '-')):
            continue
        try:
            answer = max(answer, eval(to_eval))
        except SyntaxError as err:
            pass
    return answer


def main():
    print(solve(input()))


if __name__ == '__main__':
    main()
0