結果

問題 No.1330 Multiply or Divide
ユーザー SSRS
提出日時 2021-01-08 21:59:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 177,744 KB
実行使用メモリ 48,896 KB
最終ジャッジ日時 2024-11-16 11:38:08
合計ジャッジ時間 6,488 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 32 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N, M, P;
  cin >> N >> M >> P;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(N, 0);
  dp[0] = 1;
  vector<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;
      }
    }
    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