結果
問題 |
No.1172 Add Recursive Sequence
|
ユーザー |
|
提出日時 | 2020-08-15 13:20:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 1,640 ms |
コンパイル使用メモリ | 169,036 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-10-10 17:44:47 |
合計ジャッジ時間 | 8,716 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 TLE * 1 -- * 3 |
ソースコード
#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]); } }