結果

問題 No.2561 みんな大好きmod 998
ユーザー e60e256e60e256
提出日時 2023-12-02 17:20:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 4,000 ms
コード長 687 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,188 KB
最終ジャッジ日時 2023-12-02 17:20:40
合計ジャッジ時間 6,740 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,332 KB
testcase_01 AC 124 ms
76,484 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 277 ms
76,944 KB
testcase_04 AC 281 ms
76,944 KB
testcase_05 AC 269 ms
76,944 KB
testcase_06 AC 259 ms
76,944 KB
testcase_07 AC 34 ms
53,332 KB
testcase_08 AC 33 ms
53,332 KB
testcase_09 AC 67 ms
70,416 KB
testcase_10 AC 36 ms
53,332 KB
testcase_11 AC 122 ms
76,052 KB
testcase_12 AC 34 ms
53,332 KB
testcase_13 AC 33 ms
53,332 KB
testcase_14 AC 32 ms
53,332 KB
testcase_15 AC 286 ms
77,188 KB
testcase_16 AC 32 ms
53,332 KB
testcase_17 AC 32 ms
53,332 KB
testcase_18 AC 33 ms
53,332 KB
testcase_19 AC 236 ms
76,396 KB
testcase_20 AC 45 ms
62,272 KB
testcase_21 AC 34 ms
53,332 KB
testcase_22 AC 35 ms
53,332 KB
testcase_23 AC 33 ms
53,332 KB
testcase_24 AC 34 ms
53,332 KB
testcase_25 AC 32 ms
53,332 KB
testcase_26 AC 103 ms
75,628 KB
testcase_27 AC 290 ms
76,944 KB
testcase_28 AC 138 ms
76,176 KB
testcase_29 AC 107 ms
75,996 KB
testcase_30 AC 153 ms
76,384 KB
testcase_31 AC 187 ms
76,692 KB
testcase_32 AC 82 ms
75,500 KB
testcase_33 AC 108 ms
76,000 KB
testcase_34 AC 280 ms
76,944 KB
testcase_35 AC 102 ms
75,920 KB
testcase_36 AC 96 ms
75,920 KB
testcase_37 AC 73 ms
75,524 KB
testcase_38 AC 119 ms
76,052 KB
testcase_39 AC 188 ms
76,380 KB
testcase_40 AC 170 ms
76,380 KB
testcase_41 AC 121 ms
76,052 KB
testcase_42 AC 136 ms
76,176 KB
testcase_43 AC 69 ms
75,524 KB
testcase_44 AC 96 ms
75,652 KB
testcase_45 AC 186 ms
75,884 KB
testcase_46 AC 95 ms
75,920 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-(K-1-la)):
        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