結果

問題 No.505 カードの数式2
コンテスト
ユーザー Kohei
提出日時 2026-11-01 16:00:53
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 34 ms / 2,000 ms
+ 156µs
コード長 463 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 85 ms
コンパイル使用メモリ 64,380 KB
実行使用メモリ 53,632 KB
最終ジャッジ日時 2026-11-01 16:00:57
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = list(map(int, input().split()))

def warizan(a, b):
    if a*b > 0:
        return abs(a)//abs(b)
    else:
        return -(abs(a)//abs(b))

m, M = A[0], A[0]
for i in range(1, N):
    a = A[i]
    candi = []
    for num in [m, M]:
        candi.append(num + a)
        candi.append(num - a)
        candi.append(num * a)
        if a != 0:
            candi.append(warizan(num, a))
    candi.sort()
    m, M = candi[0], candi[-1]

print(M)
0