結果

問題 No.2215 Slide Subset Sum
ユーザー ShirotsumeShirotsume
提出日時 2023-01-07 11:58:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,399 ms / 3,000 ms
コード長 1,495 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 432,332 KB
最終ジャッジ日時 2023-09-17 10:38:17
合計ジャッジ時間 33,359 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 366 ms
114,668 KB
testcase_01 AC 944 ms
111,528 KB
testcase_02 AC 965 ms
114,172 KB
testcase_03 AC 967 ms
112,756 KB
testcase_04 AC 1,091 ms
243,072 KB
testcase_05 AC 121 ms
81,388 KB
testcase_06 AC 124 ms
80,916 KB
testcase_07 AC 121 ms
81,280 KB
testcase_08 AC 121 ms
80,944 KB
testcase_09 AC 121 ms
81,288 KB
testcase_10 AC 121 ms
81,128 KB
testcase_11 AC 125 ms
81,236 KB
testcase_12 AC 134 ms
85,708 KB
testcase_13 AC 135 ms
86,212 KB
testcase_14 AC 135 ms
85,604 KB
testcase_15 AC 122 ms
81,104 KB
testcase_16 AC 141 ms
86,448 KB
testcase_17 AC 1,151 ms
293,084 KB
testcase_18 AC 1,109 ms
285,380 KB
testcase_19 AC 1,070 ms
199,116 KB
testcase_20 AC 1,056 ms
359,624 KB
testcase_21 AC 1,205 ms
281,316 KB
testcase_22 AC 1,057 ms
359,072 KB
testcase_23 AC 1,157 ms
428,904 KB
testcase_24 AC 1,399 ms
432,332 KB
testcase_25 AC 1,142 ms
409,684 KB
testcase_26 AC 1,046 ms
359,564 KB
testcase_27 AC 195 ms
89,824 KB
testcase_28 AC 210 ms
102,244 KB
testcase_29 AC 224 ms
98,356 KB
testcase_30 AC 511 ms
102,040 KB
testcase_31 AC 466 ms
212,232 KB
testcase_32 AC 237 ms
97,236 KB
testcase_33 AC 852 ms
287,996 KB
testcase_34 AC 691 ms
270,100 KB
testcase_35 AC 246 ms
99,740 KB
testcase_36 AC 329 ms
146,704 KB
testcase_37 AC 640 ms
280,944 KB
testcase_38 AC 237 ms
117,572 KB
testcase_39 AC 940 ms
111,448 KB
testcase_40 AC 272 ms
114,576 KB
testcase_41 AC 119 ms
81,032 KB
testcase_42 AC 1,048 ms
359,796 KB
testcase_43 AC 1,245 ms
280,156 KB
testcase_44 AC 1,251 ms
280,360 KB
testcase_45 AC 1,112 ms
400,932 KB
testcase_46 AC 1,181 ms
401,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
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 = []
_ = [0] * 10 ** 6
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)




        

0