結果

問題 No.2561 みんな大好きmod 998
ユーザー けんぴんけんぴん
提出日時 2023-11-06 00:39:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 317 ms / 4,000 ms
コード長 607 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 187,588 KB
最終ジャッジ日時 2023-11-06 00:40:03
合計ジャッジ時間 7,134 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,612 KB
testcase_01 AC 77 ms
80,548 KB
testcase_02 AC 42 ms
53,612 KB
testcase_03 AC 303 ms
187,360 KB
testcase_04 AC 293 ms
187,356 KB
testcase_05 AC 291 ms
187,364 KB
testcase_06 AC 279 ms
187,360 KB
testcase_07 AC 43 ms
55,660 KB
testcase_08 AC 42 ms
53,612 KB
testcase_09 AC 50 ms
64,352 KB
testcase_10 AC 42 ms
53,612 KB
testcase_11 AC 90 ms
84,084 KB
testcase_12 AC 42 ms
55,660 KB
testcase_13 AC 41 ms
55,660 KB
testcase_14 AC 42 ms
55,660 KB
testcase_15 AC 282 ms
187,588 KB
testcase_16 AC 41 ms
55,660 KB
testcase_17 AC 40 ms
53,612 KB
testcase_18 AC 41 ms
55,660 KB
testcase_19 AC 233 ms
158,884 KB
testcase_20 AC 46 ms
59,704 KB
testcase_21 AC 43 ms
53,612 KB
testcase_22 AC 43 ms
53,612 KB
testcase_23 AC 42 ms
55,660 KB
testcase_24 AC 40 ms
53,612 KB
testcase_25 AC 42 ms
53,612 KB
testcase_26 AC 87 ms
84,304 KB
testcase_27 AC 291 ms
187,356 KB
testcase_28 AC 117 ms
101,620 KB
testcase_29 AC 82 ms
83,028 KB
testcase_30 AC 129 ms
106,336 KB
testcase_31 AC 187 ms
136,564 KB
testcase_32 AC 78 ms
82,896 KB
testcase_33 AC 80 ms
83,024 KB
testcase_34 AC 317 ms
187,352 KB
testcase_35 AC 61 ms
73,140 KB
testcase_36 AC 61 ms
73,148 KB
testcase_37 AC 60 ms
68,520 KB
testcase_38 AC 92 ms
84,084 KB
testcase_39 AC 130 ms
106,328 KB
testcase_40 AC 129 ms
106,336 KB
testcase_41 AC 84 ms
84,084 KB
testcase_42 AC 117 ms
101,612 KB
testcase_43 AC 60 ms
68,520 KB
testcase_44 AC 88 ms
84,180 KB
testcase_45 AC 230 ms
158,784 KB
testcase_46 AC 68 ms
77,792 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()
    for j in range(l+1,N-K+1+i):
        if i == K-1:
            if (s+A[j]) % 998244353 <= (s+A[j]) % 998:
                ans += 1
        else:
            q.append([i+1,j,s+A[j]])
print(ans % 998)
0