結果

問題 No.616 へんなソート
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-12 19:16:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,888 KB
実行使用メモリ 63,104 KB
最終ジャッジ日時 2024-04-25 22:52:36
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,240 KB
testcase_01 AC 36 ms
52,492 KB
testcase_02 AC 37 ms
52,688 KB
testcase_03 AC 41 ms
60,752 KB
testcase_04 AC 41 ms
59,916 KB
testcase_05 AC 36 ms
53,764 KB
testcase_06 AC 42 ms
60,724 KB
testcase_07 AC 42 ms
59,432 KB
testcase_08 AC 43 ms
59,820 KB
testcase_09 AC 43 ms
60,036 KB
testcase_10 AC 41 ms
59,868 KB
testcase_11 AC 41 ms
59,664 KB
testcase_12 AC 47 ms
61,296 KB
testcase_13 AC 85 ms
63,044 KB
testcase_14 AC 47 ms
62,344 KB
testcase_15 AC 42 ms
60,020 KB
testcase_16 AC 43 ms
59,952 KB
testcase_17 AC 65 ms
63,028 KB
testcase_18 AC 48 ms
61,076 KB
testcase_19 AC 47 ms
61,648 KB
testcase_20 AC 41 ms
60,336 KB
testcase_21 AC 42 ms
61,424 KB
testcase_22 AC 44 ms
60,332 KB
testcase_23 AC 36 ms
52,816 KB
testcase_24 AC 36 ms
53,664 KB
testcase_25 AC 35 ms
52,600 KB
testcase_26 AC 37 ms
51,824 KB
testcase_27 AC 34 ms
53,844 KB
testcase_28 AC 150 ms
63,104 KB
testcase_29 AC 152 ms
62,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9+7
n, k = map(int, input().split())
mod = 10**9+7
dp = [1]*(k+2)
tmp = [0]*(k+2)
for i in range(1, n+1):
    for j in range(k+1):
        dp[j+1] = (dp[j+1] + dp[j]) % mod
        tmp[j] = dp[j]
        if j-i+1 > 0:
            tmp[j] = (tmp[j] - dp[j-i]) % mod
    dp, tmp = tmp, dp
print(dp[k])
0