結果

問題 No.2062 Sum of Subset mod 999630629
ユーザー 👑 rin204rin204
提出日時 2022-08-26 22:42:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 431 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 85,632 KB
最終ジャッジ日時 2024-04-22 00:47:37
合計ジャッジ時間 3,277 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 37 ms
52,096 KB
testcase_02 AC 37 ms
51,456 KB
testcase_03 AC 37 ms
51,456 KB
testcase_04 AC 37 ms
51,712 KB
testcase_05 AC 36 ms
51,968 KB
testcase_06 AC 37 ms
51,840 KB
testcase_07 AC 37 ms
51,456 KB
testcase_08 AC 65 ms
78,208 KB
testcase_09 AC 59 ms
74,112 KB
testcase_10 AC 63 ms
72,320 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 61 ms
76,288 KB
testcase_24 AC 60 ms
76,288 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
MOD2 = 999630629

n = int(input())
A = list(map(int, input().split()))
times = pow(2, n - 1, MOD)
ans = sum(A) * times % MOD

x = sum(A) - MOD2

if x < 0:
    print(ans)
    exit()

dp = {0:1}
A.sort(reverse = True)
for a in A:
    ndp = {}
    for k, v in dp.items():
        if a + k <= x:
            ndp[a + k] = ndp.get(a + k, 0) + v
    dp = ndp

tot = sum(dp.values()) - 1
ans -= tot * MOD2
print(ans % MOD)
0