結果

問題 No.505 カードの数式2
ユーザー ntuda
提出日時 2024-12-17 22:21:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 670,708 KB
最終ジャッジ日時 2024-12-17 22:21:42
合計ジャッジ時間 8,334 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 27 MLE * 1 OLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
N = int(input())
A = list(map(int, input().split()))
Q = {A[0]}
for a in A[1:]:
    Q2 = set()
    while Q:
        x = next(iter(Q))
        Q.remove(x)
        Q2.add(x + a)
        Q2.add(x - a)
        Q2.add(x * a)
        if a != 0:
            if x * a > 0:
                Q2.add(x // a)
            else:
                Q2.add(-((-x)//a))
    Q = Q2
    print(Q)
print(max(list(Q)))
0