結果

問題 No.1011 Infinite Stairs
ユーザー kappybarkappybar
提出日時 2020-03-29 12:34:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 168,244 KB
実行使用メモリ 109,504 KB
最終ジャッジ日時 2023-09-24 11:11:14
合計ジャッジ時間 3,985 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 6 ms
4,660 KB
testcase_03 AC 225 ms
72,928 KB
testcase_04 AC 37 ms
14,956 KB
testcase_05 AC 335 ms
109,504 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 48 ms
17,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 30 ms
11,704 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 39 ms
14,412 KB
testcase_16 AC 155 ms
52,572 KB
testcase_17 AC 14 ms
7,352 KB
testcase_18 AC 94 ms
31,412 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 38 ms
14,376 KB
testcase_22 AC 72 ms
26,228 KB
testcase_23 AC 43 ms
16,812 KB
testcase_24 AC 47 ms
17,808 KB
testcase_25 AC 78 ms
27,312 KB
testcase_26 AC 17 ms
7,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
        int n,d,k;
        cin >> n >> d >> k;
        vector<vector<int>> dp(n+1,vector<int>(k+1));
        dp[0][0] = 1;

        for(int i=1;i<=n;i++){
                for(int j=0;j<=k;j++){
                        if(j > 0 && j-d-1 >= 0) dp[i][j] = ((dp[i-1][j-1] + dp[i][j-1])%MOD - dp[i-1][j-d-1] + MOD)%MOD;
                        else if(j > 0) dp[i][j] = (dp[i-1][j-1] + dp[i][j-1])%MOD;
                        else  dp[i][j] = 0;
                }
        }

        cout << dp[n][k] << endl;
        return 0;
}



0