結果

問題 No.1011 Infinite Stairs
ユーザー granddaifukugranddaifuku
提出日時 2020-04-28 01:25:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 169,508 KB
実行使用メモリ 215,540 KB
最終ジャッジ日時 2023-09-24 11:12:57
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 6 ms
5,920 KB
testcase_03 AC 228 ms
143,156 KB
testcase_04 AC 41 ms
26,472 KB
testcase_05 AC 347 ms
215,540 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 4 ms
4,664 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 49 ms
31,524 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 30 ms
20,544 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 38 ms
25,768 KB
testcase_16 AC 160 ms
100,984 KB
testcase_17 AC 16 ms
11,200 KB
testcase_18 AC 94 ms
59,596 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 41 ms
26,000 KB
testcase_22 AC 79 ms
49,432 KB
testcase_23 AC 48 ms
30,836 KB
testcase_24 AC 52 ms
33,348 KB
testcase_25 AC 84 ms
52,388 KB
testcase_26 AC 18 ms
13,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, d, k;
    cin >> n >> d >> k;
    vector<vector<ll> > dp(n + 1, vector<ll>(k + 2));
    dp[0][0] = 1;
    rep (i, n) {
        rep (j, k) {
            int l, r;
            l = j + 1;
            r = j + d + 1;
            r = min(r, k + 1);
            if (l > k) continue;
            dp[i + 1][l] += dp[i][j];
            dp[i + 1][r] -= dp[i][j];
        }
        FOR (j, 1, k + 1) {
            dp[i + 1][j] += dp[i + 1][j - 1];
            if (dp[i + 1][j] < 0) dp[i + 1][j] += MOD;
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][k] << endl;
    
    return 0;
}

0