結果

問題 No.2561 みんな大好きmod 998
ユーザー e60e256e60e256
提出日時 2023-12-02 17:21:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 418 ms / 4,000 ms
コード長 678 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,224 KB
最終ジャッジ日時 2023-12-02 17:21:34
合計ジャッジ時間 9,022 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,332 KB
testcase_01 AC 167 ms
76,672 KB
testcase_02 AC 38 ms
53,332 KB
testcase_03 AC 416 ms
77,224 KB
testcase_04 AC 378 ms
76,660 KB
testcase_05 AC 391 ms
76,660 KB
testcase_06 AC 379 ms
76,664 KB
testcase_07 AC 39 ms
53,332 KB
testcase_08 AC 39 ms
53,332 KB
testcase_09 AC 69 ms
70,440 KB
testcase_10 AC 38 ms
53,332 KB
testcase_11 AC 140 ms
75,920 KB
testcase_12 AC 38 ms
53,332 KB
testcase_13 AC 38 ms
53,332 KB
testcase_14 AC 38 ms
53,332 KB
testcase_15 AC 418 ms
76,788 KB
testcase_16 AC 41 ms
53,332 KB
testcase_17 AC 41 ms
53,332 KB
testcase_18 AC 43 ms
53,332 KB
testcase_19 AC 388 ms
76,956 KB
testcase_20 AC 47 ms
59,704 KB
testcase_21 AC 38 ms
53,332 KB
testcase_22 AC 38 ms
53,332 KB
testcase_23 AC 39 ms
53,332 KB
testcase_24 AC 40 ms
53,332 KB
testcase_25 AC 38 ms
53,332 KB
testcase_26 AC 160 ms
75,912 KB
testcase_27 AC 377 ms
76,660 KB
testcase_28 AC 170 ms
75,904 KB
testcase_29 AC 119 ms
75,776 KB
testcase_30 AC 191 ms
76,032 KB
testcase_31 AC 269 ms
76,404 KB
testcase_32 AC 114 ms
75,772 KB
testcase_33 AC 119 ms
75,776 KB
testcase_34 AC 378 ms
76,660 KB
testcase_35 AC 105 ms
75,764 KB
testcase_36 AC 107 ms
75,764 KB
testcase_37 AC 92 ms
75,652 KB
testcase_38 AC 145 ms
75,920 KB
testcase_39 AC 194 ms
76,032 KB
testcase_40 AC 196 ms
76,032 KB
testcase_41 AC 141 ms
75,920 KB
testcase_42 AC 171 ms
75,904 KB
testcase_43 AC 92 ms
75,652 KB
testcase_44 AC 128 ms
75,780 KB
testcase_45 AC 325 ms
76,444 KB
testcase_46 AC 110 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = list(map(int, input().split()))

itemsum = 0

# 全探索でやったらTLEになった。

arr = []
ans = 0
def choose_rec(K, N):
    global itemsum
    global ans
    if (len(arr) == K):
        S998 = itemsum % 998
        S998244353 = itemsum % 998244353
        if (S998244353 <= S998):
            ans = ans + 1
        return
    if (len(arr) == 0):
        s = 1
    else:
        s = arr[-1] + 1    
    la = len(arr)
    #print(K-1-la)
    for i in range(s, N+1):
        arr.append(i)
        itemsum += A[i-1]
        choose_rec(K, N)
        itemsum -= A[i-1]
        arr.pop()
    return

choose_rec(K, N)
    
print(ans % 998)
0