結果

問題 No.1011 Infinite Stairs
ユーザー NOSSNOSS
提出日時 2020-03-20 21:45:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 694 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 170,224 KB
実行使用メモリ 217,472 KB
最終ジャッジ日時 2023-09-24 10:55:47
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 6 ms
6,340 KB
testcase_03 AC 422 ms
144,108 KB
testcase_04 AC 69 ms
26,956 KB
testcase_05 AC 694 ms
217,472 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 4 ms
4,988 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,740 KB
testcase_11 AC 80 ms
32,116 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 47 ms
20,800 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 64 ms
26,120 KB
testcase_16 AC 275 ms
102,072 KB
testcase_17 AC 17 ms
11,644 KB
testcase_18 AC 158 ms
59,744 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 58 ms
26,812 KB
testcase_22 AC 130 ms
49,524 KB
testcase_23 AC 76 ms
31,496 KB
testcase_24 AC 80 ms
33,780 KB
testcase_25 AC 135 ms
52,432 KB
testcase_26 AC 24 ms
13,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;

int main(){
    int N, D, K;
    cin >> N >> D >> K;
    vector<vector<ll> > dp(K+1, vector<ll>(N+1));
    for(int i=0;i<=K;i++){
        dp[i][0] = 1;
    }
    for(int j=0;j<N;j++){
        for(int i=0;i<K;i++){
            if(i < D){
                dp[i+1][j+1] = (dp[i][j] + dp[i][j+1]) % MOD;
            }else{
                dp[i+1][j+1] = (dp[i][j] - dp[i-D][j] + dp[i][j+1] + MOD) % MOD;
            }
        }
    }
    cout << (dp[K][N]-dp[K-1][N]+MOD)%MOD << endl;
    return 0;
}
0