結果

問題 No.1011 Infinite Stairs
ユーザー granddaifukugranddaifuku
提出日時 2020-04-28 01:38:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 1,570 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 170,424 KB
実行使用メモリ 216,964 KB
最終ジャッジ日時 2023-09-24 11:12:53
合計ジャッジ時間 4,987 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 12 ms
9,320 KB
testcase_03 AC 235 ms
143,224 KB
testcase_04 AC 305 ms
216,964 KB
testcase_05 AC 356 ms
216,832 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 39 ms
28,016 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 12 ms
10,364 KB
testcase_11 AC 137 ms
92,088 KB
testcase_12 AC 6 ms
6,196 KB
testcase_13 AC 73 ms
49,220 KB
testcase_14 AC 7 ms
6,676 KB
testcase_15 AC 51 ms
32,696 KB
testcase_16 AC 235 ms
150,240 KB
testcase_17 AC 225 ms
161,388 KB
testcase_18 AC 109 ms
66,332 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 10 ms
8,852 KB
testcase_21 AC 57 ms
36,768 KB
testcase_22 AC 200 ms
136,708 KB
testcase_23 AC 56 ms
35,400 KB
testcase_24 AC 55 ms
33,900 KB
testcase_25 AC 107 ms
65,836 KB
testcase_26 AC 27 ms
18,340 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;
    //     }
    // }
    vector<vector<ll> > dp(n + 1, vector<ll>(n * d + d + 10));
    dp[0][0] = 1;
    rep (i, n) {
        rep (j, n * d) {
            int l, r;
            l = j + 1;
            r = j + d + 1;
            if (l > k) break;
            dp[i + 1][l] += dp[i][j];
            dp[i + 1][r] -= dp[i][j];
        }
        FOR (j, 1, n * d + d + 10) {
            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