結果

問題 No.2561 みんな大好きmod 998
ユーザー けんぴんけんぴん
提出日時 2023-11-06 00:41:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,159 ms / 4,000 ms
コード長 584 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 422,740 KB
最終ジャッジ日時 2023-11-06 00:41:22
合計ジャッジ時間 15,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,528 KB
testcase_01 AC 81 ms
82,008 KB
testcase_02 AC 47 ms
53,528 KB
testcase_03 AC 1,123 ms
422,676 KB
testcase_04 AC 1,159 ms
422,716 KB
testcase_05 AC 1,087 ms
422,716 KB
testcase_06 AC 1,082 ms
422,716 KB
testcase_07 AC 44 ms
55,580 KB
testcase_08 AC 43 ms
53,532 KB
testcase_09 AC 53 ms
64,276 KB
testcase_10 AC 42 ms
53,532 KB
testcase_11 AC 156 ms
125,312 KB
testcase_12 AC 43 ms
55,580 KB
testcase_13 AC 44 ms
55,580 KB
testcase_14 AC 45 ms
55,580 KB
testcase_15 AC 1,079 ms
422,740 KB
testcase_16 AC 43 ms
55,580 KB
testcase_17 AC 42 ms
53,532 KB
testcase_18 AC 44 ms
55,580 KB
testcase_19 AC 732 ms
346,844 KB
testcase_20 AC 49 ms
61,884 KB
testcase_21 AC 42 ms
53,532 KB
testcase_22 AC 41 ms
53,532 KB
testcase_23 AC 43 ms
55,580 KB
testcase_24 AC 44 ms
53,532 KB
testcase_25 AC 43 ms
53,532 KB
testcase_26 AC 198 ms
146,512 KB
testcase_27 AC 1,078 ms
422,720 KB
testcase_28 AC 293 ms
187,276 KB
testcase_29 AC 121 ms
106,180 KB
testcase_30 AC 248 ms
176,660 KB
testcase_31 AC 519 ms
286,704 KB
testcase_32 AC 127 ms
105,944 KB
testcase_33 AC 121 ms
106,184 KB
testcase_34 AC 1,060 ms
422,720 KB
testcase_35 AC 85 ms
84,468 KB
testcase_36 AC 87 ms
84,468 KB
testcase_37 AC 81 ms
84,236 KB
testcase_38 AC 154 ms
125,316 KB
testcase_39 AC 248 ms
176,660 KB
testcase_40 AC 245 ms
176,664 KB
testcase_41 AC 169 ms
125,316 KB
testcase_42 AC 271 ms
187,284 KB
testcase_43 AC 82 ms
84,236 KB
testcase_44 AC 128 ms
107,396 KB
testcase_45 AC 697 ms
346,844 KB
testcase_46 AC 119 ms
105,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 非再帰BFS (K個目をqに入れて取り出した時に判定)
from collections import deque

N,K = map(int,input().split())
assert 1 <= N <= 28
assert 1 <= K <= min(8,N)
A = list(map(int,input().split()))
for a in A:
    assert 0 <= a <= 998244352
ans = 0
# [i,l,s]: i個選んだ,今まで選んだ数字のうち一番後ろのindexはl,和はs
q = deque([[0,-1,0]])
while q:
    i,l,s = q.popleft()
    if i == K:
        if s % 998244353 <= s % 998:
            ans += 1
        continue
    for j in range(l+1,N-K+1+i):
        q.append([i+1,j,s+A[j]])
print(ans % 998)
0