結果
| 問題 |
No.1331 Moving Penguin
|
| コンテスト | |
| ユーザー |
snow39
|
| 提出日時 | 2021-01-08 21:54:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,235 bytes |
| コンパイル時間 | 1,205 ms |
| コンパイル使用メモリ | 95,688 KB |
| 実行使用メモリ | 82,560 KB |
| 最終ジャッジ日時 | 2024-11-16 11:20:56 |
| 合計ジャッジ時間 | 15,131 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 WA * 12 RE * 2 TLE * 1 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}
void add(ll &a,ll b){
a=(a+b)%MOD;
}
void mul(ll &a,ll b){
a%=MOD;b%=MOD;
a=a*b%MOD;
}
const int B=100;
ll dp[100010][B+1];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
vector<int> A(N);
rep(i,N) cin>>A[i];
dp[0][0]=1;
for(int i=0;i<N;i++){
ll value=0;
for(int j=0;j<=B;j++) add(value,dp[i][j]);
if(A[i]<=B){
for(int j=1;j<=B;j++){
if(i+j<=N) add(dp[i+j][j],dp[i][j]);
if(j==A[i]) add(dp[i+j][j],value);
}
}else{
int now=i;
while(now+A[i]<=N){
now+=A[i];
add(dp[now][0],value);
}
}
if(A[i]>1) add(dp[i+1][0],value);
}
ll ans=0;
for(int j=0;j<=B;j++) add(ans,dp[N-1][j]);
cout<<ans<<endl;
return 0;
}
snow39