結果
問題 |
No.193 筒の数式
|
ユーザー |
![]() |
提出日時 | 2016-03-01 19:16:44 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 729 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-24 13:08:51 |
合計ジャッジ時間 | 1,521 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 4 |
ソースコード
#!/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()