結果

問題 No.1011 Infinite Stairs
ユーザー i_am_nicolen_22i_am_nicolen_22
提出日時 2020-03-20 22:40:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 2,016 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 165,692 KB
実行使用メモリ 230,748 KB
最終ジャッジ日時 2023-09-24 11:01:18
合計ジャッジ時間 3,827 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,388 KB
testcase_01 AC 2 ms
7,424 KB
testcase_02 AC 42 ms
193,792 KB
testcase_03 AC 165 ms
218,068 KB
testcase_04 AC 66 ms
228,832 KB
testcase_05 AC 230 ms
230,748 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 27 ms
122,220 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
5,408 KB
testcase_10 AC 13 ms
54,760 KB
testcase_11 AC 64 ms
204,372 KB
testcase_12 AC 12 ms
54,576 KB
testcase_13 AC 37 ms
110,492 KB
testcase_14 AC 15 ms
68,940 KB
testcase_15 AC 53 ms
165,496 KB
testcase_16 AC 126 ms
205,108 KB
testcase_17 AC 49 ms
214,404 KB
testcase_18 AC 80 ms
158,056 KB
testcase_19 AC 10 ms
42,352 KB
testcase_20 AC 9 ms
40,204 KB
testcase_21 AC 41 ms
102,328 KB
testcase_22 AC 76 ms
182,164 KB
testcase_23 AC 43 ms
92,080 KB
testcase_24 AC 51 ms
122,680 KB
testcase_25 AC 80 ms
184,164 KB
testcase_26 AC 24 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int dp[310][310*310];
constexpr ll MOD = 1e9 + 7;
signed main()
{
    int n,d,k;
    cin>>n>>d>>k;
    dp[0][0]=1;
    
    //xはi回目で行ける上限

    for (int i = 1; i <= n; i++)
    {
        vector<int>rui(k+2,0);
        rui[0]=0;
        for (int j = 0; j <= k; j++)
        {
            rui[j+1]=(dp[i-1][j]+rui[j])%MOD;
            rui[j+1]%=MOD;
        }
    //    show(rui);
        
        for(int j=0;j<=k;j++){
             dp[i][j] = rui[j] - rui[max(j-d,0LL)];
             dp[i][j]%=MOD;
        }
    // cerr << dp[1][2] << endl;
    }
    cout<<(dp[n][k]+MOD)%MOD<<endl;
    return 0;
}
0