結果
問題 | No.2215 Slide Subset Sum |
ユーザー | vwxyz |
提出日時 | 2023-09-06 19:45:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,866 ms / 3,000 ms |
コード長 | 1,500 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 87,012 KB |
実行使用メモリ | 444,036 KB |
最終ジャッジ日時 | 2023-09-06 19:46:26 |
合計ジャッジ時間 | 45,975 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 560 ms
166,336 KB |
testcase_01 | AC | 1,250 ms
443,632 KB |
testcase_02 | AC | 1,866 ms
437,076 KB |
testcase_03 | AC | 1,759 ms
438,100 KB |
testcase_04 | AC | 1,666 ms
437,628 KB |
testcase_05 | AC | 212 ms
91,312 KB |
testcase_06 | AC | 214 ms
91,080 KB |
testcase_07 | AC | 246 ms
91,228 KB |
testcase_08 | AC | 212 ms
91,028 KB |
testcase_09 | AC | 213 ms
91,044 KB |
testcase_10 | AC | 225 ms
91,048 KB |
testcase_11 | AC | 212 ms
91,236 KB |
testcase_12 | AC | 248 ms
94,356 KB |
testcase_13 | AC | 230 ms
94,860 KB |
testcase_14 | AC | 230 ms
94,460 KB |
testcase_15 | AC | 218 ms
91,388 KB |
testcase_16 | AC | 244 ms
95,764 KB |
testcase_17 | AC | 1,560 ms
437,620 KB |
testcase_18 | AC | 1,537 ms
437,724 KB |
testcase_19 | AC | 1,689 ms
438,752 KB |
testcase_20 | AC | 1,525 ms
437,508 KB |
testcase_21 | AC | 1,627 ms
438,292 KB |
testcase_22 | AC | 1,484 ms
437,300 KB |
testcase_23 | AC | 1,356 ms
436,872 KB |
testcase_24 | AC | 1,353 ms
436,728 KB |
testcase_25 | AC | 1,402 ms
437,320 KB |
testcase_26 | AC | 1,485 ms
437,436 KB |
testcase_27 | AC | 300 ms
107,960 KB |
testcase_28 | AC | 293 ms
112,044 KB |
testcase_29 | AC | 361 ms
119,320 KB |
testcase_30 | AC | 829 ms
252,040 KB |
testcase_31 | AC | 589 ms
214,864 KB |
testcase_32 | AC | 359 ms
125,180 KB |
testcase_33 | AC | 1,089 ms
307,928 KB |
testcase_34 | AC | 883 ms
272,388 KB |
testcase_35 | AC | 357 ms
121,864 KB |
testcase_36 | AC | 452 ms
164,220 KB |
testcase_37 | AC | 1,341 ms
436,836 KB |
testcase_38 | AC | 303 ms
144,888 KB |
testcase_39 | AC | 1,145 ms
444,036 KB |
testcase_40 | AC | 370 ms
144,792 KB |
testcase_41 | AC | 217 ms
91,436 KB |
testcase_42 | AC | 1,481 ms
437,588 KB |
testcase_43 | AC | 1,651 ms
438,008 KB |
testcase_44 | AC | 1,716 ms
438,472 KB |
testcase_45 | AC | 1,430 ms
437,044 KB |
testcase_46 | AC | 1,440 ms
437,120 KB |
ソースコード
import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') N,M,K=map(int,readline().split()) A=list(map(int,readline().split())) mod=998244353 left=[[0]*K for i in range(N+1)] right=[[0]*K for i in range(N+1)] left[0][0]=1 right[N][0]=1 for i in range(1,N+1): if (i-1)%M==0: left[i][0]+=1 left[i][A[i-1]%K]+=1 else: for k in range(K): left[i][k]+=left[i-1][k] left[i][k]+=left[i-1][(k-A[i-1])%K] left[i][k]%=mod for i in range(N-1,-1,-1): if i%M==0: right[i][0]=1 else: for k in range(K): right[i][k]+=right[i+1][k] right[i][k]+=right[i+1][(k-A[i])%K] right[i][k]%=mod for i in range(N-M+1): ans=(sum(right[i][k]*left[i+M][(-k)%K]%mod for k in range(K))-1)%mod print(ans)