結果

問題 No.1011 Infinite Stairs
ユーザー Manuel1024Manuel1024
提出日時 2022-12-12 02:34:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 460 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 247,040 KB
最終ジャッジ日時 2024-04-23 20:32:54
合計ジャッジ時間 8,107 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
14,208 KB
testcase_01 AC 17 ms
16,512 KB
testcase_02 AC 397 ms
212,608 KB
testcase_03 AC 437 ms
235,392 KB
testcase_04 AC 460 ms
247,040 KB
testcase_05 AC 459 ms
247,040 KB
testcase_06 AC 10 ms
12,800 KB
testcase_07 AC 246 ms
136,448 KB
testcase_08 AC 10 ms
12,800 KB
testcase_09 AC 14 ms
15,104 KB
testcase_10 AC 115 ms
66,688 KB
testcase_11 AC 411 ms
222,720 KB
testcase_12 AC 111 ms
65,920 KB
testcase_13 AC 221 ms
124,800 KB
testcase_14 AC 142 ms
82,432 KB
testcase_15 AC 338 ms
181,120 KB
testcase_16 AC 409 ms
221,184 KB
testcase_17 AC 431 ms
233,856 KB
testcase_18 AC 320 ms
173,312 KB
testcase_19 AC 89 ms
52,864 KB
testcase_20 AC 84 ms
51,840 KB
testcase_21 AC 210 ms
115,328 KB
testcase_22 AC 365 ms
198,400 KB
testcase_23 AC 187 ms
105,088 KB
testcase_24 AC 252 ms
136,576 KB
testcase_25 AC 366 ms
199,936 KB
testcase_26 AC 143 ms
83,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll MOD = 1'000'000'007;

int main(){
    int n, d, k; cin >> n >> d >> k;
    vector<vector<ll>> dp(n+10, vector<ll>(100010, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100000; j++){
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= MOD;
            dp[i+1][min(j+d+1, 100005)] -= dp[i][j];
            dp[i+1][min(j+d+1, 100005)] += MOD;
            dp[i+1][min(j+d+1, 100005)] %= MOD;
        }
        for(int j = 0; j < 100000; j++){
            dp[i+1][j+1] += dp[i+1][j];
            dp[i+1][j+1] %= MOD;
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}
0