結果

問題 No.1011 Infinite Stairs
ユーザー hanyuhanyu
提出日時 2020-04-03 15:14:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 170,376 KB
実行使用メモリ 215,508 KB
最終ジャッジ日時 2023-09-24 11:11:39
合計ジャッジ時間 3,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 6 ms
5,864 KB
testcase_03 AC 204 ms
143,108 KB
testcase_04 AC 37 ms
26,488 KB
testcase_05 AC 309 ms
215,508 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,548 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 44 ms
31,440 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 28 ms
20,372 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 36 ms
25,732 KB
testcase_16 AC 146 ms
100,924 KB
testcase_17 AC 14 ms
11,156 KB
testcase_18 AC 86 ms
59,464 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 36 ms
25,940 KB
testcase_22 AC 71 ms
49,224 KB
testcase_23 AC 43 ms
30,716 KB
testcase_24 AC 48 ms
33,324 KB
testcase_25 AC 76 ms
52,476 KB
testcase_26 AC 17 ms
13,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
static const ll 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));
  for (int j = 0; j <= k; j++) dp.at(0).at(j) = 1;
  
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j - 1 - d >= 0) dp.at(i).at(j) = MOD + dp.at(i - 1).at(j - 1) - dp.at(i - 1).at(j - 1 - d);
      else dp.at(i).at(j) = dp.at(i - 1).at(j - 1);
      dp.at(i).at(j) += dp.at(i).at(j - 1);
      dp.at(i).at(j) %= MOD;
    }
  }
  
  cout << (MOD + dp.at(n).at(k) - dp.at(n).at(k - 1)) % MOD << '\n';
}
0