結果

問題 No.505 カードの数式2
ユーザー ntudantuda
提出日時 2024-12-17 22:15:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 54,308 KB
最終ジャッジ日時 2024-12-17 22:15:51
合計ジャッジ時間 2,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,948 KB
testcase_01 AC 39 ms
53,052 KB
testcase_02 AC 39 ms
52,620 KB
testcase_03 AC 39 ms
52,968 KB
testcase_04 AC 38 ms
52,688 KB
testcase_05 AC 39 ms
52,264 KB
testcase_06 AC 39 ms
53,756 KB
testcase_07 AC 38 ms
52,740 KB
testcase_08 AC 39 ms
53,104 KB
testcase_09 AC 38 ms
53,020 KB
testcase_10 AC 38 ms
52,504 KB
testcase_11 AC 37 ms
53,936 KB
testcase_12 AC 37 ms
53,212 KB
testcase_13 AC 40 ms
53,012 KB
testcase_14 AC 38 ms
52,392 KB
testcase_15 AC 39 ms
52,620 KB
testcase_16 AC 39 ms
53,420 KB
testcase_17 WA -
testcase_18 AC 38 ms
52,464 KB
testcase_19 AC 39 ms
53,436 KB
testcase_20 AC 38 ms
53,296 KB
testcase_21 AC 40 ms
52,728 KB
testcase_22 AC 39 ms
54,308 KB
testcase_23 AC 38 ms
52,948 KB
testcase_24 AC 38 ms
53,956 KB
testcase_25 AC 40 ms
52,408 KB
testcase_26 AC 38 ms
52,908 KB
testcase_27 AC 39 ms
52,536 KB
testcase_28 AC 38 ms
52,700 KB
testcase_29 WA -
testcase_30 AC 39 ms
53,092 KB
testcase_31 AC 40 ms
54,024 KB
権限があれば一括ダウンロードができます

ソースコード

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:
            Q2.add(x // a)
    Q2 = sorted(list(Q2))
    Q = set()
    Q.add(Q2[0])
    Q.add(Q2[-1])
    if Q2[-1] > 0:
        Q.add(Q2[bisect_left(Q2,0)])
    if Q2[0] < 0:
        Q.add(Q2[bisect_left(Q2,0) - 1])
print(max(list(Q)))
0