結果

問題 No.505 カードの数式2
ユーザー vwxyzvwxyz
提出日時 2022-04-08 10:59:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 305 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 86,484 KB
実行使用メモリ 529,876 KB
最終ジャッジ日時 2023-08-18 20:16:20
合計ジャッジ時間 10,097 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,472 KB
testcase_01 AC 72 ms
71,004 KB
testcase_02 AC 87 ms
81,592 KB
testcase_03 AC 70 ms
70,932 KB
testcase_04 AC 71 ms
71,176 KB
testcase_05 AC 70 ms
70,804 KB
testcase_06 AC 73 ms
71,028 KB
testcase_07 AC 73 ms
71,072 KB
testcase_08 AC 73 ms
70,960 KB
testcase_09 AC 73 ms
71,024 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 72 ms
71,112 KB
testcase_13 AC 75 ms
70,972 KB
testcase_14 AC 72 ms
70,916 KB
testcase_15 AC 70 ms
70,824 KB
testcase_16 AC 72 ms
71,180 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 71 ms
70,628 KB
testcase_20 AC 71 ms
71,008 KB
testcase_21 AC 70 ms
71,184 KB
testcase_22 AC 1,061 ms
335,276 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1,280 ms
316,120 KB
testcase_27 AC 1,271 ms
344,096 KB
testcase_28 MLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A=map(int,readline().split())
dp=set()
dp.add(next(A))
for a in A:
    prev=dp
    dp=set()
    dp|={i+a for i in prev}
    dp|={i-a for i in prev}
    dp|={i*a for i in prev}
    if a:
        dp|={(-i)//a*(-1) for i in dp}
ans=max(dp)
print(ans)
0