結果

問題 No.505 カードの数式2
ユーザー ntuda
提出日時 2024-12-18 19:43:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 53,788 KB
最終ジャッジ日時 2024-12-18 19:43:52
合計ジャッジ時間 2,568 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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

Q = [A[0]]
for a in A[1:]:
    Q2 = []
    while Q:
        x = Q.pop()
        Q2.append(x * a)
        Q2.append(x + a)
        Q2.append(x - a)
        if a * x > 0:
            Q2.append(x//a)
        elif a * x < 0:
            Q2.append(-(-x//a))
    Q = [min(Q2),max(Q2)]

print(max(Q))
0