結果

問題 No.1011 Infinite Stairs
ユーザー taklimonetaklimone
提出日時 2020-03-21 15:30:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 198,420 KB
実行使用メモリ 109,388 KB
最終ジャッジ日時 2023-09-24 11:06:36
合計ジャッジ時間 3,918 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
5,492 KB
testcase_02 AC 23 ms
93,432 KB
testcase_03 AC 148 ms
105,012 KB
testcase_04 AC 45 ms
107,928 KB
testcase_05 AC 218 ms
109,388 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 15 ms
58,824 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 8 ms
28,000 KB
testcase_11 AC 47 ms
97,828 KB
testcase_12 AC 7 ms
28,072 KB
testcase_13 AC 28 ms
52,844 KB
testcase_14 AC 8 ms
34,084 KB
testcase_15 AC 37 ms
79,392 KB
testcase_16 AC 112 ms
98,476 KB
testcase_17 AC 29 ms
101,988 KB
testcase_18 AC 67 ms
75,748 KB
testcase_19 AC 6 ms
21,808 KB
testcase_20 AC 5 ms
19,840 KB
testcase_21 AC 31 ms
48,756 KB
testcase_22 AC 63 ms
87,840 KB
testcase_23 AC 35 ms
44,872 KB
testcase_24 AC 40 ms
59,152 KB
testcase_25 AC 66 ms
87,860 KB
testcase_26 AC 18 ms
34,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int const mod = 1000000007;
int N,d,K;
int dp[310][90010] = {};
int sum[90010] = {};

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

    cin >> N >> d >> K;
    dp[0][1] = 1;
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=K+1; ++j) sum[j] = (sum[j - 1] + dp[i - 1][j]) % mod;
        for(int j=1; j<=K+1; ++j) {
            dp[i][j] = (sum[j - 1] - sum[max(j - d - 1, 0)]) % mod;
            dp[i][j] = (dp[i][j] + mod) % mod;
        }
    }
    cout << dp[N][K + 1] << '\n';
}
0