結果
| 問題 | No.770 Median Sequence |
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2018-12-18 08:19:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 281 ms / 2,000 ms |
| コード長 | 1,018 bytes |
| コンパイル時間 | 1,063 ms |
| コンパイル使用メモリ | 95,496 KB |
| 実行使用メモリ | 144,256 KB |
| 最終ジャッジ日時 | 2024-09-25 07:41:38 |
| 合計ジャッジ時間 | 5,011 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
int n; cin>>n;
ll dp[2][3001][3001]={};
dp[0][0][0]=1;
ll s[2][3001];
fill(s[0], s[0]+n+1, 1);
fill(s[1], s[1]+n+1, 0);
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
dp[0][i][j]+=(s[0][j]+s[1][j-1]);
dp[0][i][j]%=MOD;
if(j<n && i-(n-j)>0){
dp[1][i][j]+=dp[0][i-(n-j)][j+1];
}
dp[1][i][j]+=dp[1][i-1][j+1];
dp[1][i][j]+=dp[1][i-1][j];
dp[1][i][j]%=MOD;
}
s[0][0]=0; s[1][0]=0;
for(int j=1; j<=n; j++){
s[0][j]=(s[0][j-1]+dp[0][i][j])%MOD;
s[1][j]=(s[1][j-1]+dp[1][i][j])%MOD;
}
}
ll ans=(s[0][n]+s[1][n])%MOD;
cout<<ans<<endl;
return 0;
}
chocorusk