結果

問題 No.1331 Moving Penguin
ユーザー SSRSSSRS
提出日時 2021-01-08 22:02:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 666 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 179,160 KB
実行使用メモリ 460,968 KB
最終ジャッジ日時 2024-04-28 03:00:01
合計ジャッジ時間 17,656 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 41 ms
14,588 KB
testcase_05 AC 1,357 ms
404,116 KB
testcase_06 AC 1,341 ms
404,320 KB
testcase_07 AC 1,362 ms
404,188 KB
testcase_08 AC 52 ms
27,004 KB
testcase_09 AC 50 ms
27,096 KB
testcase_10 AC 51 ms
27,036 KB
testcase_11 AC 57 ms
30,172 KB
testcase_12 AC 57 ms
30,276 KB
testcase_13 AC 58 ms
30,240 KB
testcase_14 AC 122 ms
52,136 KB
testcase_15 AC 125 ms
52,004 KB
testcase_16 AC 124 ms
51,992 KB
testcase_17 AC 46 ms
26,364 KB
testcase_18 AC 45 ms
26,044 KB
testcase_19 AC 46 ms
25,040 KB
testcase_20 AC 48 ms
25,248 KB
testcase_21 AC 48 ms
26,124 KB
testcase_22 AC 47 ms
26,084 KB
testcase_23 AC 77 ms
36,412 KB
testcase_24 AC 78 ms
36,484 KB
testcase_25 AC 75 ms
36,364 KB
testcase_26 AC 149 ms
36,384 KB
testcase_27 AC 139 ms
36,004 KB
testcase_28 AC 149 ms
38,672 KB
testcase_29 AC 34 ms
9,812 KB
testcase_30 AC 36 ms
13,440 KB
testcase_31 AC 73 ms
23,424 KB
testcase_32 AC 32 ms
11,520 KB
testcase_33 AC 49 ms
17,152 KB
testcase_34 AC 80 ms
24,508 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 35 ms
13,312 KB
testcase_39 AC 138 ms
35,464 KB
testcase_40 AC 61 ms
20,224 KB
testcase_41 TLE -
testcase_42 AC 269 ms
93,812 KB
testcase_43 AC 251 ms
93,684 KB
testcase_44 AC 242 ms
93,708 KB
testcase_45 AC 91 ms
39,120 KB
testcase_46 AC 93 ms
39,204 KB
testcase_47 AC 91 ms
39,132 KB
testcase_48 AC 43 ms
23,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(N, 0);
  dp[0] = 1;
  vector<unordered_map<int, long long>> next(N);
  for (int i = 0; i < N; i++){
    for (auto P : next[i]){
      dp[i] += P.second;
      dp[i] %= MOD;
      if (i + P.first < N){
        next[i + P.first][P.first] += P.second % MOD;
      }
    }
    if (i < N - 1 && A[i] != 1){
      dp[i + 1] += dp[i];
      dp[i + 1] %= MOD;
    }
    if (i + A[i] < N){
      next[i + A[i]][A[i]] += dp[i];
    }
  }
  cout << dp[N - 1] << endl;
}
0