結果
問題 | No.193 筒の数式 |
ユーザー | はむ吉🐹 |
提出日時 | 2016-03-01 19:19:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 1,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-24 13:09:33 |
合計ジャッジ時間 | 1,463 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#!/usr/bin/env python3# -*- coding: utf-8 -*-import itertoolsINF = 2 ** 31 - 2def solve(s):answer = -INFlength = 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:t = "".join(group).lstrip("0")if t == "":t = "0"to_eval += tif to_eval.startswith(('+', '-')) or to_eval.endswith(('+', '-')):continuetry:answer = max(answer, eval(to_eval))except SyntaxError as err:passreturn answerdef main():print(solve(input()))if __name__ == '__main__':main()