結果

問題 No.2215 Slide Subset Sum
ユーザー ShirotsumeShirotsume
提出日時 2023-01-07 07:24:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,331 ms / 3,000 ms
コード長 1,580 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 424,532 KB
最終ジャッジ日時 2023-09-17 10:38:51
合計ジャッジ時間 33,929 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 434 ms
106,432 KB
testcase_01 AC 1,002 ms
105,968 KB
testcase_02 AC 1,037 ms
107,448 KB
testcase_03 AC 1,035 ms
105,528 KB
testcase_04 AC 1,199 ms
252,708 KB
testcase_05 AC 116 ms
73,356 KB
testcase_06 AC 116 ms
73,280 KB
testcase_07 AC 114 ms
73,188 KB
testcase_08 AC 112 ms
73,352 KB
testcase_09 AC 113 ms
73,172 KB
testcase_10 AC 113 ms
73,032 KB
testcase_11 AC 113 ms
73,208 KB
testcase_12 AC 122 ms
77,844 KB
testcase_13 AC 126 ms
78,276 KB
testcase_14 AC 125 ms
77,600 KB
testcase_15 AC 114 ms
73,172 KB
testcase_16 AC 135 ms
78,256 KB
testcase_17 AC 1,190 ms
282,920 KB
testcase_18 AC 1,158 ms
282,348 KB
testcase_19 AC 1,150 ms
202,700 KB
testcase_20 AC 1,115 ms
362,600 KB
testcase_21 AC 1,290 ms
277,912 KB
testcase_22 AC 1,106 ms
358,852 KB
testcase_23 AC 1,170 ms
423,068 KB
testcase_24 AC 1,174 ms
424,532 KB
testcase_25 AC 1,141 ms
405,444 KB
testcase_26 AC 1,102 ms
359,612 KB
testcase_27 AC 185 ms
81,236 KB
testcase_28 AC 198 ms
93,992 KB
testcase_29 AC 217 ms
93,480 KB
testcase_30 AC 544 ms
95,248 KB
testcase_31 AC 461 ms
204,072 KB
testcase_32 AC 230 ms
89,024 KB
testcase_33 AC 890 ms
275,984 KB
testcase_34 AC 710 ms
260,520 KB
testcase_35 AC 261 ms
94,244 KB
testcase_36 AC 332 ms
138,696 KB
testcase_37 AC 608 ms
274,152 KB
testcase_38 AC 217 ms
109,620 KB
testcase_39 AC 1,004 ms
105,976 KB
testcase_40 AC 350 ms
106,328 KB
testcase_41 AC 112 ms
73,212 KB
testcase_42 AC 1,089 ms
361,928 KB
testcase_43 AC 1,329 ms
285,416 KB
testcase_44 AC 1,331 ms
285,452 KB
testcase_45 AC 1,130 ms
394,280 KB
testcase_46 AC 1,129 ms
394,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)




        

0