結果

問題 No.1011 Infinite Stairs
ユーザー recososorecososo
提出日時 2020-04-12 15:13:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 528 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 170,436 KB
実行使用メモリ 427,336 KB
最終ジャッジ日時 2023-09-24 11:12:30
合計ジャッジ時間 4,595 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 9 ms
8,856 KB
testcase_03 AC 340 ms
281,620 KB
testcase_04 AC 58 ms
50,228 KB
testcase_05 AC 528 ms
427,336 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 6 ms
6,160 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 5 ms
5,088 KB
testcase_11 AC 73 ms
59,944 KB
testcase_12 AC 4 ms
4,772 KB
testcase_13 AC 46 ms
37,924 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 56 ms
48,488 KB
testcase_16 AC 231 ms
198,080 KB
testcase_17 AC 22 ms
19,408 KB
testcase_18 AC 143 ms
115,376 KB
testcase_19 AC 4 ms
4,488 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 60 ms
48,888 KB
testcase_22 AC 117 ms
94,732 KB
testcase_23 AC 69 ms
57,872 KB
testcase_24 AC 74 ms
62,816 KB
testcase_25 AC 119 ms
100,800 KB
testcase_26 AC 25 ms
22,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d,k;cin >> n >> d >> k;
    vector<vector<ll>> dp(n+1,vector<ll>(k+1)),ds(n+1,vector<ll>(k+1));
    dp[0][0]=1;
    for(int i=0;i<=k;i++){
        ds[0][i]=1;
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(j-d-1>=0){
                (dp[i+1][j]+=(ds[i][j-1]-ds[i][j-d-1]+mod)%mod)%=mod;
            }
            else{
                (dp[i+1][j]+=ds[i][j-1])%=mod;
            }
        }
        for(int j=1;j<=k;j++){
            ds[i+1][j]=(ds[i+1][j-1]+dp[i+1][j])%mod;
        }
    }
    cout << dp[n][k] << endl;
}
0