結果

問題 No.1331 Moving Penguin
ユーザー leaf_1415leaf_1415
提出日時 2021-01-08 22:15:41
言語 C++11
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 1,497 bytes
コンパイル時間 1,667 ms
コンパイル使用メモリ 81,512 KB
実行使用メモリ 254,208 KB
最終ジャッジ日時 2024-11-16 12:43:31
合計ジャッジ時間 11,189 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26 RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18
#define mod 1000000007
using namespace std;
typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;
const ll B = 320;
ll n;
ll a[100005];
ll dp[100005];
ll sum[B][100005];
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
rep(i, 1, n) cin >> a[i];
dp[1] = 1;
rep(i, 1, n){
if(i > 1){
if(a[i-1] != 1) dp[i] = dp[i-1];
rep(j, 1, B-1) if(i-j >= 1) dp[i] += sum[j][i-j];
dp[i] %= mod;
}
rep(j, 1, B-1){
ll s = 0;
if(i-j >= 1) s = sum[j][i-j];
sum[j][i] = s;
if(j == a[i]) sum[j][i] += dp[i];
if(sum[j][i] >= mod) sum[j][i] -= mod;
}
if(a[i] >= B){
return -1;
rep(j, 1, n){
if(i+j*a[i] > n) break;
dp[i+j*a[i]] += dp[i];
if(dp[i+j*a[i]] >= mod) dp[i+j*a[i]] -= mod;
}
}
}
cout << dp[n] << endl;
/*rep(i, 1, n) cout << sum[1][i] << " "; cout << endl;
rep(i, 1, n) cout << sum[2][i] << " "; cout << endl;
rep(i, 1, n) cout << dp[i] << " "; cout << endl;*/
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0