結果

問題 No.2215 Slide Subset Sum
ユーザー ShirotsumeShirotsume
提出日時 2023-01-07 07:36:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,260 ms / 3,000 ms
コード長 1,478 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 420,076 KB
最終ジャッジ日時 2023-09-17 10:37:41
合計ジャッジ時間 34,836 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 351 ms
106,496 KB
testcase_01 AC 931 ms
103,556 KB
testcase_02 AC 953 ms
106,432 KB
testcase_03 AC 955 ms
104,448 KB
testcase_04 AC 1,109 ms
234,956 KB
testcase_05 AC 148 ms
72,952 KB
testcase_06 AC 118 ms
73,324 KB
testcase_07 AC 118 ms
73,292 KB
testcase_08 AC 117 ms
73,540 KB
testcase_09 AC 119 ms
73,384 KB
testcase_10 AC 117 ms
72,996 KB
testcase_11 AC 119 ms
73,128 KB
testcase_12 AC 128 ms
77,824 KB
testcase_13 AC 133 ms
78,480 KB
testcase_14 AC 131 ms
77,628 KB
testcase_15 AC 118 ms
73,236 KB
testcase_16 AC 139 ms
78,500 KB
testcase_17 AC 1,173 ms
286,056 KB
testcase_18 AC 1,167 ms
285,548 KB
testcase_19 AC 1,072 ms
190,944 KB
testcase_20 AC 1,074 ms
360,296 KB
testcase_21 AC 1,220 ms
288,884 KB
testcase_22 AC 1,122 ms
362,488 KB
testcase_23 AC 1,148 ms
415,888 KB
testcase_24 AC 1,160 ms
420,076 KB
testcase_25 AC 1,119 ms
401,684 KB
testcase_26 AC 1,067 ms
361,320 KB
testcase_27 AC 190 ms
81,524 KB
testcase_28 AC 207 ms
94,220 KB
testcase_29 AC 220 ms
90,168 KB
testcase_30 AC 509 ms
94,136 KB
testcase_31 AC 464 ms
204,224 KB
testcase_32 AC 236 ms
89,284 KB
testcase_33 AC 854 ms
280,768 KB
testcase_34 AC 697 ms
262,380 KB
testcase_35 AC 247 ms
91,808 KB
testcase_36 AC 339 ms
139,008 KB
testcase_37 AC 629 ms
272,440 KB
testcase_38 AC 240 ms
110,080 KB
testcase_39 AC 941 ms
103,528 KB
testcase_40 AC 272 ms
106,332 KB
testcase_41 AC 116 ms
73,120 KB
testcase_42 AC 1,059 ms
360,096 KB
testcase_43 AC 1,260 ms
288,316 KB
testcase_44 AC 1,260 ms
288,276 KB
testcase_45 AC 1,148 ms
392,424 KB
testcase_46 AC 1,112 ms
393,732 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 = []

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