結果

問題 No.535 自然数の収納方法
ユーザー tossytossy
提出日時 2017-06-23 23:54:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,353 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 164,392 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-04-14 06:37:29
合計ジャッジ時間 5,483 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,764 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 11 ms
7,180 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 6 ms
7,720 KB
testcase_06 AC 9 ms
8,028 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long dp[2005][2005][2];
int n;

long solve(int i, int j, bool last=false){
  if(i==n-1){
    if(last) return j!=n;
    else return 1;
  }
  if(dp[i][j][last]>=0) return dp[i][j][last];

  long ret = 0;
  if(i==0) for(int k=j; k<=n; k++) ret += solve(i+1,k,j==1);
  else for(int k=max(j-i+1,1); k<=n; k++) ret += solve(i+1, k, last);
  return dp[i][j][last] = ret%MOD;
}

int main(){
  cin>>n;
  fill(dp[0][0], dp[n+1][0], -1);
  long ans = 0;
  rep(i,n) ans += solve(0,i+1);
  cout << ans %MOD << endl;

  return 0;
}
0