結果

問題 No.1331 Moving Penguin
ユーザー snow39snow39
提出日時 2021-01-08 23:19:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 607 ms / 1,500 ms
コード長 1,285 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 98,944 KB
実行使用メモリ 85,760 KB
最終ジャッジ日時 2024-04-25 04:56:47
合計ジャッジ時間 12,968 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
9,216 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 170 ms
85,632 KB
testcase_05 AC 169 ms
85,632 KB
testcase_06 AC 170 ms
85,632 KB
testcase_07 AC 169 ms
85,632 KB
testcase_08 AC 171 ms
85,632 KB
testcase_09 AC 173 ms
85,632 KB
testcase_10 AC 167 ms
85,632 KB
testcase_11 AC 166 ms
85,632 KB
testcase_12 AC 172 ms
85,632 KB
testcase_13 AC 168 ms
85,632 KB
testcase_14 AC 169 ms
85,632 KB
testcase_15 AC 174 ms
85,632 KB
testcase_16 AC 172 ms
85,632 KB
testcase_17 AC 173 ms
85,632 KB
testcase_18 AC 171 ms
85,760 KB
testcase_19 AC 166 ms
85,632 KB
testcase_20 AC 169 ms
85,504 KB
testcase_21 AC 171 ms
85,632 KB
testcase_22 AC 171 ms
85,632 KB
testcase_23 AC 172 ms
85,760 KB
testcase_24 AC 175 ms
85,632 KB
testcase_25 AC 166 ms
85,632 KB
testcase_26 AC 209 ms
85,760 KB
testcase_27 AC 209 ms
85,632 KB
testcase_28 AC 209 ms
85,632 KB
testcase_29 AC 171 ms
85,632 KB
testcase_30 AC 60 ms
30,720 KB
testcase_31 AC 113 ms
49,664 KB
testcase_32 AC 56 ms
27,392 KB
testcase_33 AC 86 ms
39,680 KB
testcase_34 AC 133 ms
58,496 KB
testcase_35 AC 607 ms
85,760 KB
testcase_36 AC 583 ms
85,632 KB
testcase_37 AC 596 ms
85,632 KB
testcase_38 AC 68 ms
32,000 KB
testcase_39 AC 197 ms
83,072 KB
testcase_40 AC 95 ms
44,288 KB
testcase_41 AC 400 ms
85,632 KB
testcase_42 AC 544 ms
85,632 KB
testcase_43 AC 559 ms
85,760 KB
testcase_44 AC 561 ms
85,632 KB
testcase_45 AC 505 ms
85,632 KB
testcase_46 AC 501 ms
85,760 KB
testcase_47 AC 523 ms
85,760 KB
testcase_48 AC 166 ms
85,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  A.pop_back();
  N--;

  vector<vector<ll>> dp(N+1,vector<ll> (B+1,0));
  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]);

    for(int j=1;j<=B;j++){
    if(i+j<=N) add(dp[i+j][j],dp[i][j]);
    }

    if(A[i]<=B){
      if(i+A[i]<=N) add(dp[i+A[i]][A[i]],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][j]);
  cout<<ans<<endl;

  return 0;
}
0