結果
問題 |
No.44 DPなすごろく
|
ユーザー |
|
提出日時 | 2022-10-14 21:40:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 1,839 ms |
コンパイル使用メモリ | 168,276 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 13:25:45 |
合計ジャッジ時間 | 2,531 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> #if 1 && defined(LOCAL) #include<LOCAL/LOCAL.hpp> #else #define debug(...) #define line #endif using namespace std; typedef long long ll; typedef long double ld; #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;} int N; vector<ll>dp; ll solve(int s){ if(s==N-1){ return 1; } if(dp[s]!=-1){ return dp[s]; } ll ret=0; if(s+1<=N-1){ ret+=solve(s+1); } if(s+2<=N-1){ ret+=solve(s+2); } return dp[s]=ret; } int main(){ cin>>N; N++; dp.assign(N,-1); cout<<solve(0)<<endl; debug(dp); }