結果

問題 No.1011 Infinite Stairs
ユーザー StrorkisStrorkis
提出日時 2020-03-21 18:30:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 69,908 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-24 11:07:04
合計ジャッジ時間 2,172 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 95 ms
4,380 KB
testcase_04 AC 17 ms
4,376 KB
testcase_05 AC 135 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 13 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 63 ms
4,380 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 36 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 16 ms
4,380 KB
testcase_22 AC 30 ms
4,380 KB
testcase_23 AC 19 ms
4,376 KB
testcase_24 AC 21 ms
4,380 KB
testcase_25 AC 33 ms
4,376 KB
testcase_26 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, d, K; cin >> N >> d >> K;
    vector<int> dp(K+1);
    for (int i = 1; i <= min(d, K); i++)
        dp[i] = 1;
    for (int i = 2; i <= N; i++) {
        for (int i = 1; i < K; i++)
            dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        for (int j = K; j >= 1; j--) {
            dp[j] = dp[j-1] - dp[max(0, j-d-1)];
            if (dp[j] < 0) dp[j] += MOD;
        }
    }
    cout << dp[K] << "\n";
}
0