結果

問題 No.1011 Infinite Stairs
ユーザー momoharamomohara
提出日時 2020-03-20 22:00:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 638 ms / 2,000 ms
コード長 1,991 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 105,264 KB
実行使用メモリ 427,308 KB
最終ジャッジ日時 2023-09-24 10:57:32
合計ジャッジ時間 4,941 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 9 ms
8,816 KB
testcase_03 AC 314 ms
281,692 KB
testcase_04 AC 58 ms
50,376 KB
testcase_05 AC 638 ms
427,308 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 5 ms
6,184 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
5,228 KB
testcase_11 AC 68 ms
60,264 KB
testcase_12 AC 3 ms
4,640 KB
testcase_13 AC 42 ms
37,852 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 55 ms
48,556 KB
testcase_16 AC 232 ms
198,160 KB
testcase_17 AC 21 ms
19,424 KB
testcase_18 AC 136 ms
115,592 KB
testcase_19 AC 3 ms
4,708 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 56 ms
48,728 KB
testcase_22 AC 112 ms
94,652 KB
testcase_23 AC 67 ms
57,928 KB
testcase_24 AC 73 ms
62,852 KB
testcase_25 AC 120 ms
100,968 KB
testcase_26 AC 25 ms
22,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9+7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	ll n, d, k;
	cin >> n >> d >> k;
	Matrix dp(n + 1, Array(k + 1, 0));
	Matrix sum(n + 1, Array(k + 2, 0));
	dp[0][0] = 1;
	sum[0][0] = 1;
	REP(i, n) {
		REP(j, k+1) {
			(dp[i + 1][j] = MOD + sum[i][j] - sum[i][max(0LL, j - d)]) %= MOD;
			(sum[i][j + 1] = dp[i][j] + sum[i][j]) %= MOD;
		}
	}
	cout << dp[n][k] << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}
0