結果

問題 No.1172 Add Recursive Sequence
ユーザー ohaini1123ohaini1123
提出日時 2020-08-15 13:20:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 877 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 164,992 KB
実行使用メモリ 11,804 KB
最終ジャッジ日時 2024-04-19 00:56:59
合計ジャッジ時間 8,657 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 8 ms
6,944 KB
testcase_10 AC 123 ms
6,940 KB
testcase_11 AC 108 ms
6,944 KB
testcase_12 AC 444 ms
6,940 KB
testcase_13 AC 390 ms
6,944 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll K,N,M;
  cin>>K>>N>>M;
  vector<ll> a(max(K,N)),c(K);
  rep(i,K) cin>>a[i];
  rep(i,K) cin>>c[i];
  for(int i = K;i<max(K,N);i++){
    rep(j,K){
      a[i] = (a[i]+a[i-j-1]*c[j])%mod;
    }
  }
  vector<ll> ans(N,0);
  rep(i,M){
    ll l,r;
    cin>>l>>r;
    for(int j = l; j < r; j++){
      ans[j] = (ans[j]+a[j-l])%mod;
    }
  }
  rep(i,N){
    printf("%lld\n",ans[i]);
  }
}
0