結果

問題 No.1011 Infinite Stairs
ユーザー snrnsidysnrnsidy
提出日時 2021-10-28 13:33:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 195,860 KB
実行使用メモリ 215,956 KB
最終ジャッジ日時 2024-04-16 13:03:08
合計ジャッジ時間 8,656 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
215,900 KB
testcase_01 AC 134 ms
215,884 KB
testcase_02 AC 146 ms
215,852 KB
testcase_03 AC 364 ms
215,680 KB
testcase_04 AC 199 ms
215,644 KB
testcase_05 AC 489 ms
215,808 KB
testcase_06 AC 135 ms
215,900 KB
testcase_07 AC 141 ms
215,928 KB
testcase_08 AC 135 ms
215,936 KB
testcase_09 AC 135 ms
215,896 KB
testcase_10 AC 140 ms
215,808 KB
testcase_11 AC 188 ms
215,772 KB
testcase_12 AC 139 ms
215,904 KB
testcase_13 AC 167 ms
215,936 KB
testcase_14 AC 138 ms
215,916 KB
testcase_15 AC 177 ms
215,680 KB
testcase_16 AC 299 ms
215,836 KB
testcase_17 AC 155 ms
215,772 KB
testcase_18 AC 232 ms
215,956 KB
testcase_19 AC 153 ms
215,748 KB
testcase_20 AC 135 ms
215,768 KB
testcase_21 AC 174 ms
215,936 KB
testcase_22 AC 214 ms
215,936 KB
testcase_23 AC 188 ms
215,820 KB
testcase_24 AC 188 ms
215,904 KB
testcase_25 AC 219 ms
215,860 KB
testcase_26 AC 153 ms
215,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const long long int MOD = 1e9 + 7;
long long int dp[301][90001];
long long int psum[90001];

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

    int n,d,k;

    cin >> n >> d >> k;

    memset(dp,0,sizeof(dp));

    dp[0][0] = 1;
    for(int i=0;i<n;i++)
    {
        memset(psum,0,sizeof(psum));
        psum[0] = dp[i][0];
        for(int j=1;j<=k;j++)
        {
            psum[j] += psum[j-1];
            psum[j]%=MOD;
            psum[j] += dp[i][j];
            psum[j]%=MOD;
        }

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

    cout << dp[n][k] << '\n';
    return 0;
}
0