結果

問題 No.616 へんなソート
ユーザー ああいいああいい
提出日時 2022-03-30 19:34:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 251,100 KB
最終ジャッジ日時 2024-04-27 09:22:23
合計ジャッジ時間 3,467 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,376 KB
testcase_01 AC 32 ms
52,156 KB
testcase_02 AC 33 ms
53,560 KB
testcase_03 AC 40 ms
61,096 KB
testcase_04 AC 41 ms
61,636 KB
testcase_05 AC 32 ms
52,616 KB
testcase_06 AC 40 ms
60,740 KB
testcase_07 AC 40 ms
60,336 KB
testcase_08 AC 42 ms
62,136 KB
testcase_09 AC 43 ms
62,576 KB
testcase_10 AC 42 ms
61,036 KB
testcase_11 AC 42 ms
62,656 KB
testcase_12 AC 51 ms
65,392 KB
testcase_13 AC 172 ms
136,224 KB
testcase_14 AC 51 ms
64,948 KB
testcase_15 AC 42 ms
60,816 KB
testcase_16 AC 42 ms
62,964 KB
testcase_17 AC 91 ms
76,684 KB
testcase_18 AC 51 ms
69,708 KB
testcase_19 AC 53 ms
69,720 KB
testcase_20 AC 40 ms
62,044 KB
testcase_21 AC 41 ms
61,312 KB
testcase_22 AC 42 ms
64,772 KB
testcase_23 AC 32 ms
52,636 KB
testcase_24 AC 32 ms
52,616 KB
testcase_25 AC 32 ms
52,504 KB
testcase_26 AC 32 ms
52,616 KB
testcase_27 AC 34 ms
52,860 KB
testcase_28 AC 380 ms
250,992 KB
testcase_29 AC 378 ms
251,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

a.sort()
P = 10 ** 9 + 7
dp = [0] * (K+1)
dp[0] = 1
for i in range(N):
    nx = [0] * (K + 1)
    S = [0] * (K + 2)
    for j in range(K+1):
        S[j+1] = (S[j] + dp[j]) % P
    for j in range(K+1):
        tmp = S[j+1] - S[max(0,j-i)]
        nx[j] += tmp

    
    for u in range(K+1):
        nx[u] %= P
    dp = nx
ans = 0
for i in dp:
    ans = (ans + i) % P
print(ans)
0