結果

問題 No.616 へんなソート
ユーザー roarisroaris
提出日時 2020-12-04 18:22:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 609 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 232,404 KB
最終ジャッジ日時 2023-10-13 07:57:38
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,344 KB
testcase_01 AC 72 ms
71,280 KB
testcase_02 AC 72 ms
71,436 KB
testcase_03 AC 81 ms
76,436 KB
testcase_04 AC 81 ms
76,360 KB
testcase_05 AC 73 ms
71,284 KB
testcase_06 AC 81 ms
76,536 KB
testcase_07 AC 79 ms
76,260 KB
testcase_08 AC 80 ms
76,228 KB
testcase_09 AC 82 ms
76,196 KB
testcase_10 AC 78 ms
76,352 KB
testcase_11 AC 82 ms
76,536 KB
testcase_12 AC 87 ms
76,288 KB
testcase_13 AC 241 ms
120,668 KB
testcase_14 AC 88 ms
76,532 KB
testcase_15 AC 78 ms
76,216 KB
testcase_16 AC 79 ms
76,216 KB
testcase_17 AC 162 ms
95,192 KB
testcase_18 AC 97 ms
79,092 KB
testcase_19 AC 98 ms
79,500 KB
testcase_20 AC 80 ms
76,188 KB
testcase_21 AC 79 ms
76,240 KB
testcase_22 AC 81 ms
76,604 KB
testcase_23 AC 72 ms
71,552 KB
testcase_24 AC 72 ms
71,176 KB
testcase_25 AC 70 ms
71,496 KB
testcase_26 AC 69 ms
71,328 KB
testcase_27 AC 70 ms
71,288 KB
testcase_28 AC 547 ms
232,404 KB
testcase_29 AC 609 ms
232,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
dp = [[0]*(K+1) for _ in range(N+1)]
dp[1][0] = 1
MOD = 10**9+7

for i in range(2, N+1):
    acc = [0]
    
    for j in range(K+1):
        acc.append((acc[-1]+dp[i-1][j])%MOD)
    
    for j in range(K+1):
        dp[i][j] = (acc[j+1]-acc[max(0, j-(i-1))])%MOD

print(sum(dp[N][:K+1])%MOD)
0