結果
問題 |
No.1172 Add Recursive Sequence
|
ユーザー |
![]() |
提出日時 | 2025-03-31 18:00:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 970 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 106,880 KB |
最終ジャッジ日時 | 2025-03-31 18:02:02 |
合計ジャッジ時間 | 10,188 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 TLE * 1 -- * 3 |
ソースコード
MOD = 10**9 + 7 def main(): import sys input = sys.stdin.read().split() idx = 0 K = int(input[idx]); idx +=1 N = int(input[idx]); idx +=1 M = int(input[idx]); idx +=1 a = list(map(int, input[idx:idx+K])) idx +=K a = [aa % MOD for aa in a] c = list(map(int, input[idx:idx+K])) idx +=K c = [cc % MOD for cc in c] # Precompute a up to N-1 for i in range(K, N): ai = 0 for k in range(1, K+1): ai += c[k-1] * a[i -k] ai %= MOD a.append(ai % MOD) # Process all operations and accumulate into x x = [0] * (N) for _ in range(M): l = int(input[idx]); idx +=1 r = int(input[idx]); idx +=1 d = r - l for s in range(d): p = l + s if p >= N: break x[p] = (x[p] + a[s]) % MOD for xi in x: print(xi % MOD) if __name__ == '__main__': main()