結果
問題 | No.2215 Slide Subset Sum |
ユーザー | Shirotsume |
提出日時 | 2023-01-07 07:24:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,288 ms / 3,000 ms |
コード長 | 1,580 bytes |
コンパイル時間 | 354 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 422,928 KB |
最終ジャッジ日時 | 2024-07-04 06:48:09 |
合計ジャッジ時間 | 31,001 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 347 ms
104,960 KB |
testcase_01 | AC | 908 ms
105,216 KB |
testcase_02 | AC | 951 ms
105,344 KB |
testcase_03 | AC | 957 ms
105,344 KB |
testcase_04 | AC | 1,092 ms
240,608 KB |
testcase_05 | AC | 43 ms
55,424 KB |
testcase_06 | AC | 43 ms
56,320 KB |
testcase_07 | AC | 44 ms
55,552 KB |
testcase_08 | AC | 41 ms
55,552 KB |
testcase_09 | AC | 43 ms
55,680 KB |
testcase_10 | AC | 44 ms
55,680 KB |
testcase_11 | AC | 44 ms
55,168 KB |
testcase_12 | AC | 54 ms
64,256 KB |
testcase_13 | AC | 57 ms
66,304 KB |
testcase_14 | AC | 58 ms
65,152 KB |
testcase_15 | AC | 46 ms
56,064 KB |
testcase_16 | AC | 64 ms
69,504 KB |
testcase_17 | AC | 1,134 ms
285,564 KB |
testcase_18 | AC | 1,104 ms
277,840 KB |
testcase_19 | AC | 1,053 ms
192,724 KB |
testcase_20 | AC | 925 ms
280,712 KB |
testcase_21 | AC | 1,183 ms
276,748 KB |
testcase_22 | AC | 1,032 ms
356,048 KB |
testcase_23 | AC | 1,129 ms
422,276 KB |
testcase_24 | AC | 1,125 ms
422,928 KB |
testcase_25 | AC | 1,089 ms
405,120 KB |
testcase_26 | AC | 1,095 ms
357,844 KB |
testcase_27 | AC | 126 ms
79,360 KB |
testcase_28 | AC | 139 ms
92,032 KB |
testcase_29 | AC | 160 ms
92,288 KB |
testcase_30 | AC | 482 ms
92,672 KB |
testcase_31 | AC | 376 ms
188,672 KB |
testcase_32 | AC | 167 ms
88,192 KB |
testcase_33 | AC | 849 ms
285,336 KB |
testcase_34 | AC | 634 ms
258,064 KB |
testcase_35 | AC | 200 ms
93,184 KB |
testcase_36 | AC | 261 ms
134,784 KB |
testcase_37 | AC | 539 ms
264,328 KB |
testcase_38 | AC | 144 ms
108,172 KB |
testcase_39 | AC | 909 ms
105,348 KB |
testcase_40 | AC | 254 ms
104,320 KB |
testcase_41 | AC | 44 ms
55,808 KB |
testcase_42 | AC | 951 ms
284,044 KB |
testcase_43 | AC | 1,288 ms
283,848 KB |
testcase_44 | AC | 1,282 ms
284,468 KB |
testcase_45 | AC | 1,066 ms
375,900 KB |
testcase_46 | AC | 1,075 ms
375,880 KB |
ソースコード
import sys from collections import deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 import random n, m, k = mi() a = li() MAXI = k valuetop = [] valuebottom = [] dptop = [] dpbottom = [] X = [0] * MAXI X[0] = 1 dptop.append(X) dpbottom.append(X) def push(x): valuebottom.append(x) ndp = [0] * MAXI for v in range(MAXI): ndp[(v+x)%MAXI] += dpbottom[-1][v] ndp[v] += dpbottom[-1][v] ndp[(v+x)%MAXI] %= mod ndp[v] %= mod dpbottom.append(ndp) def pop(): if not valuetop: valuebottom.reverse() for x in valuebottom: ndp = [0] * MAXI for v in range(MAXI): ndp[(v+x)%MAXI] += dptop[-1][v] ndp[v] += dptop[-1][v] ndp[(v+x)%MAXI] %= mod ndp[v] %= mod dptop.append(ndp) valuetop.append(x) while valuebottom: valuebottom.pop() while len(dpbottom) > 1: dpbottom.pop() dptop.pop() valuetop.pop() def fold(): ans = 0 for v in range(MAXI): ans += dptop[-1][v] * dpbottom[-1][(MAXI-v) % MAXI] ans %= mod return ans for i in range(m): push(a[i]) ans = [] ans.append(fold()) for i in range(m, n): pop() push(a[i]) ans.append(fold()) for v in ans: print((v-1) % mod)