結果

問題 No.1011 Infinite Stairs
ユーザー erbowlerbowl
提出日時 2020-04-29 13:39:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 203,868 KB
実行使用メモリ 431,924 KB
最終ジャッジ日時 2023-09-24 11:13:41
合計ジャッジ時間 5,096 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 8 ms
9,228 KB
testcase_03 AC 309 ms
284,896 KB
testcase_04 AC 56 ms
50,872 KB
testcase_05 AC 472 ms
431,924 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
6,552 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
5,540 KB
testcase_11 AC 68 ms
60,972 KB
testcase_12 AC 4 ms
4,964 KB
testcase_13 AC 43 ms
38,740 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 54 ms
49,016 KB
testcase_16 AC 222 ms
201,236 KB
testcase_17 AC 21 ms
19,924 KB
testcase_18 AC 129 ms
116,780 KB
testcase_19 AC 3 ms
5,032 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 57 ms
50,096 KB
testcase_22 AC 107 ms
95,952 KB
testcase_23 AC 68 ms
60,112 KB
testcase_24 AC 73 ms
63,952 KB
testcase_25 AC 113 ms
101,452 KB
testcase_26 AC 26 ms
23,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,d,k;
    std::cin >> n>>d>>k;
    
    vector<vector<ll>> dp(k+2,vector<ll>(n+1,0));
    vector<vector<ll>> sum(k+2,vector<ll>(n+1,0));
    dp[0][0] = 1;
    sum[1][0]= 1;
    for (int i = 1; i <= k; i++) {
        sum[i+1][0] = sum[i][0];
    }
    
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n; j++) {
            dp[i+1][j+1] = sum[i+1][j]-sum[max(0ll,i-(d-1))][j]+(ll)1e9+7;
            dp[i+1][j+1] %= (ll)1e9+7;
            sum[i+2][j+1]= sum[i+1][j+1]+dp[i+1][j+1];
            sum[i+2][j+1]%= (ll)1e9+7;
        }
    }

    std::cout << dp[k][n] << std::endl;
}

0