#P6434. Dessert Selection

    ID: 19648 Type: Default 1000ms 256MiB

Dessert Selection

Dessert Selection

You are given nn desserts, each with a deliciousness value aia_i. You want to choose exactly kk desserts from these nn and arrange them in an order for tasting. However, the tasting order must satisfy the following conditions for every ii (2ik2\le i\le k):

[ \text{(1) } a_i \geq l \times a_{i-1}, \quad \text{(2) } a_i \leq r \times a_{i-1}. ]<br>
Note: In counting the number of valid selections, different tasting orders of the same set of kk desserts are considered as one unique combination.

Your task is to compute two values modulo 109+710^9+7:

  • The number of valid dessert combinations.
  • The maximum possible sum of the deliciousness values among all valid combinations.
If no valid combination exists, output both values as 0.

inputFormat

The first line contains four integers: nn, kk, ll, and rr.

The second line contains nn integers, where the ii-th integer represents aia_i, the deliciousness value of the ii-th dessert.

outputFormat

Output two space-separated integers: the number of valid combinations and the maximum sum of deliciousness values among these valid combinations, both taken modulo 109+710^9+7.

sample

4 2 1 2
1 2 3 4
4 7