#P17317. [KismetOI 2026 I] 作弊

    ID: 19730 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>动态规划 DPO2优化差分DP 套 DP

[KismetOI 2026 I] 作弊

Problem Description

cobeder has started holding rated contests. Little A participated in nn contests, and the perf value of the ii-th contest is pip_i (∣pi∣≤V|p_i| \le V). The cobeder system has a constant kk and an array g0∼kVg_{0 \sim kV}. Little A’s rating can be computed as follows:

  • If n≤kn \le k, then the rating equals $g_{\max\limits_{i=0}^{n}(\sum\limits_{j=1}^{i}p_j)}$.
  • If n>kn > k, let $\text{maxp} = \max\limits_{i=0}^{k}(\sum\limits_{j=1}^{i}p_j)$. Then the rating equals gmaxp×(∑i=1npi)g_{\text{maxp}} \times (\sum\limits_{i=1}^{n}p_i).

In particular, when i=0i=0, set ∑j=1ipj=0\sum\limits_{j=1}^{i}p_j=0.

Little A hacked into cobeder’s system and wants to take this chance to modify his rating. Specifically, Little A has an integer DD (∣D∣≤V|D| \le V). He may choose some contests 1≤i1<i2<i3<⋯<im≤n1 \le i_1 < i_2 < i_3 < \dots < i_m \le n such that, when computing the rating and if n>kn > k, during the computation of (∑i=1npi)(\sum\limits_{i=1}^{n}p_i), the values pi1,pi2,…,pimp_{i_1}, p_{i_2}, \dots, p_{i_m} are all replaced by DD (that is, it does not affect the case n≤kn \le k, nor does it affect the value of maxp\text{maxp} when n≥kn \ge k).

To avoid being exposed, it must hold that for 1≤x<m1 \le x < m, ix+1>ix+1i_{x+1} > i_x + 1. Let f(p)f(p) denote, for a perf sequence p1∼np_{1\sim n}, the maximum rating value he can finally obtain after modifications.

Since cobeder computes the perf value of each contest a bit slowly, Little A only obtained some of the perf values. Specifically, Little A got a sequence p1∼np_{1\sim n} of length nn, where pi=−7912p_i = -7912 means the perf value for this contest has not been computed yet, but it must be some integer in [−V,V][-V, V].

Little A wants to know: given n,k,D,Vn, k, D, V and p1∼n,g0∼kVp_{1\sim n}, g_{0\sim kV}, over all possible final perf sequences p1∼np_{1\sim n}, what is the sum of f(p)f(p)? Output the answer modulo 109+710^9 + 7.

Input Format

The first line contains four integers n,k,D,Vn, k, D, V.

The second line contains nn integers p1∼np_{1\sim n}.

The third line contains kV+1kV + 1 integers g0∼kVg_{0\sim kV}.

Output Format

Output one integer in one line, representing the answer.

3 2 2 3
-7912 3 -2
1 1 2 3 4 5 5
152
5 2 2 3
-1 3 -2 -7912 -7912
0 0 2 3 3 4 5
900
5 2 2 3
-7912 3 -2 -7912 -7912
0 0 2 3 3 4 5
7895
5 7 2 5
-5 -7912 0 -7912 -7912 
0 0 0 168 303 303 508 508 508 690 690 828 828 828 1005 1005 1005 1190 1190 1190 1190 1190 1190 1217 1217 1287 1600 1600 1600 1600 1600 1600 1600 1600 1600 1600
45661

Hint

Sample Explanation #1

One possible original perf sequence pp is 0,3,−20, 3, -2. Then gmaxp=g3=3g_{\text{maxp}} = g_3 = 3. One optimal operation is to modify p1,p3p_1, p_3 to 22, and then for this sequence, f(p)=3(2+3+2)=21f(p) = 3(2+3+2)=21.

Constraints

For all data, it holds that:

  • 1≤k≤301 \le k \le 30.
  • 0≤V≤300 \le V \le 30.
  • ∣D∣≤V|D| \le V.
  • pi∈{−7912}∪[−V,V]p_i \in \{-7912\}\cup [-V,V] and each pip_i is an integer.
  • 1≤n≤1051 \le n \le 10^5.
  • 0≤gi≤1090 \le g_i \le 10^9, and for 0≤i<kV0 \le i < kV, it is guaranteed that gi≤gi+1g_i \le g_{i+1}.

::cute-table{tuack} | Subtask\text{Subtask} | n≤n\le | k≤k \le | V≤V \le | gi≤g_i \le | Special Properties | Score | | :--------------: | :----: | :------: | :------: | :--------: | :----------------: | :--: | | #1 | 10510^5 | 3030 | 3030 | 10910^9 | All gig_i are the same. | 11 | | #2 | 55 | 55 | 55 | ^ | n≤kn \le k. | 44 | | #3 | 3030 | 3030 | 3030 | ^ | None. | 55 | | #4 | 500500 | 1010 | 1010 | ^ | ^ | 1515 | | #5 | 10510^5 | 3030 | 3030 | 55 | ^ | 1515 | | #6 | ^ | 1010 | 1010 | 10910^9 | ^ | 2020 | | #7 | ^ | 3030 | 3030 | ^ | For all ii with pi=−7912p_i = -7912, it holds that i>ki > k. | 1515 | | #8 | ^ | ^ | ^ | ^ | None. | 2525 |

Translated by ChatGPT 5