結果
問題 |
No.505 カードの数式2
|
ユーザー |
![]() |
提出日時 | 2020-02-26 13:05:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-10-13 15:17:16 |
合計ジャッジ時間 | 2,172 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% N, *A = map(int, read().split()) # %% def divide(x, y): if x == 0: return 0 if not ((x > 0) ^ (y > 0)): return x // y return - ((-x) // y) # %% def gen_nums(x, y): yield x + y yield x - y yield x * y if y != 0: yield divide(x, y) # %% dp = A[0], A[0] for x in A[1:]: nums = list(gen_nums(dp[0], x)) + list(gen_nums(dp[1], x)) dp = min(nums), max(nums) print(dp[1])