結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
![]() |
提出日時 | 2020-06-06 02:58:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,185 bytes |
コンパイル時間 | 635 ms |
コンパイル使用メモリ | 70,532 KB |
実行使用メモリ | 13,644 KB |
最終ジャッジ日時 | 2024-12-21 08:35:38 |
合計ジャッジ時間 | 48,047 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 3 WA * 6 TLE * 15 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <numeric> using namespace std; using ll = long long; template <class T> using grid = vector<vector<T>>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define input(...) __VA_ARGS__; in(__VA_ARGS__) void print() { std::cout << std::endl; } template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { std::cout << head << " "; print(std::forward<Tail>(tail)...); } void in() { } template <class Head, class... Tail> void in(Head&& head, Tail&&... tail) { cin >> head; in(std::forward<Tail>(tail)...); } int main() { int input(N, d, K); vector<ll> dp(K + 1); REP(k, K + 1) { // n == 1 の時 if (k <= 0) dp[k] = 0; else dp[k] = (int) k <= d; } vector<ll> cumsum(K + 1); REP(n, N - 1) { // [0, N - 1) FORD(k, K, 1) { // [K, 1] partial_sum(dp.begin(), dp.end(), cumsum.begin()); dp[k] = cumsum[k - 1] - cumsum[max(1ll, k - d) - 1]; // cumsum[a] - cumsum[b - 1] = sum(dp[b] ~ dp[a]) } } print(dp[K]); }