結果

問題 No.1331 Moving Penguin
ユーザー snow39snow39
提出日時 2021-01-08 22:57:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,268 bytes
コンパイル時間 917 ms
コンパイル使用メモリ 95,836 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-04-28 04:38:24
合計ジャッジ時間 11,110 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 142 ms
82,432 KB
testcase_05 AC 165 ms
82,560 KB
testcase_06 AC 163 ms
82,560 KB
testcase_07 AC 164 ms
82,560 KB
testcase_08 AC 163 ms
82,432 KB
testcase_09 AC 165 ms
82,560 KB
testcase_10 AC 164 ms
82,432 KB
testcase_11 AC 164 ms
82,432 KB
testcase_12 AC 163 ms
82,560 KB
testcase_13 AC 164 ms
82,560 KB
testcase_14 AC 164 ms
82,560 KB
testcase_15 AC 165 ms
82,432 KB
testcase_16 AC 163 ms
82,688 KB
testcase_17 AC 167 ms
82,560 KB
testcase_18 AC 164 ms
82,560 KB
testcase_19 AC 165 ms
82,432 KB
testcase_20 AC 166 ms
82,560 KB
testcase_21 AC 169 ms
82,560 KB
testcase_22 AC 167 ms
82,560 KB
testcase_23 AC 165 ms
82,560 KB
testcase_24 AC 165 ms
82,432 KB
testcase_25 AC 164 ms
82,560 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 142 ms
82,560 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 386 ms
82,432 KB
testcase_36 AC 368 ms
82,560 KB
testcase_37 AC 372 ms
82,560 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 307 ms
82,560 KB
testcase_42 AC 356 ms
82,560 KB
testcase_43 AC 374 ms
82,560 KB
testcase_44 AC 357 ms
82,560 KB
testcase_45 AC 355 ms
82,560 KB
testcase_46 AC 341 ms
82,432 KB
testcase_47 AC 333 ms
82,560 KB
testcase_48 AC 166 ms
82,560 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;

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

  A.pop_back();
  N--;

  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(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