#P6434. 「EZEC-1」甜品

「EZEC-1」甜品

Background

X likes desserts the most.

School is about to start, but X has not finished his homework. He walks sadly on the street. Suddenly, he finds a newly opened dessert shop, and his sadness disappears. He then walks into the dessert shop.

Problem Description

X finds that there are a total of nn kinds of desserts in the shop. He wants to pick kk of them and taste them in a certain order.

Each dessert has a deliciousness value aia_i. X is picky about the eating order: he does not want the deliciousness values of two consecutive desserts to differ by too little, otherwise he cannot tell the difference between them; but he also does not want them to differ by too much, otherwise the huge taste impact will be unbearable. He is very conflicted and does not know how to choose, so he asks you for help.

You need to choose kk desserts from the nn desserts, and for the ii-th dessert (i[2,k]i \in [2, k]), it must satisfy the following two conditions:

  • The deliciousness value of the ii-th dessert must be greater than or equal to ll times that of the (i1)(i-1)-th dessert.
  • The deliciousness value of the ii-th dessert must be less than or equal to rr times that of the (i1)(i-1)-th dessert.

How many valid selections are there? What is the maximum possible sum of deliciousness values among the kk chosen desserts?

Since the answers may be too large, you need to take both results modulo 10000000071000000007 (109+710^9+7).

Note: The number of selections only considers which kk desserts are chosen, and does not consider the order. That is, if there exists a set of kk desserts such that tasting them in different orders all satisfies the conditions, it is still counted as only one selection.

Input Format

The first line contains four positive integers: n,k,l,rn, k, l, r.

The second line contains nn positive integers: aia_i.

Output Format

The first line contains one integer, the total number of valid selections.

The second line contains one integer, the maximum sum of deliciousness values.

If there is no valid selection, output 00 for both lines.

4 3 2 3
7 5 3 1
1
11
5 2 4 4
1 4 5 20 80
3
100
20 3 2 5
88 24 35 53 5 44 45 30 29 43 46 33 21 24 64 43 23 71 63 53 
33
153
5 5 2 4
1 2 3 4 5
0
0

Hint

[Sample Explanation]

Sample 1: You can only choose (4,3,1)(4, 3, 1), so there is 11 selection.

Sample 2: (1,2)(1, 2) or (3,4)(3, 4) or (4,5)(4, 5), so there are 33 selections. The maximum sum of deliciousness values is (4,5)(4, 5), which is 100100.


[Constraints]

Test Point ID nn \le kk \le aia_i \le
141 \sim 4 2020 33 100100
585 \sim 8 10310^3 44 10310^3
9129 \sim 12 10510^5 1010 10510^5
131613 \sim 16 2×1062\times 10^6 10910^9
172017 \sim 20
  • For 90%90\% of the testdata, aia_i is randomly generated.
  • For 100%100\% of the testdata, k10k \le 10, kn2×106k \le n \le 2\times 10^6, 1lr101 \le l \le r \le 10, ai109a_i \le 10^9.

Translated by ChatGPT 5