#P6434. Dessert Selection
Dessert Selection
Dessert Selection
You are given desserts, each with a deliciousness value . You want to choose exactly desserts from these and arrange them in an order for tasting. However, the tasting order must satisfy the following conditions for every ():
[
\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 desserts are considered as one unique combination.
Your task is to compute two values modulo :
- The number of valid dessert combinations.
- The maximum possible sum of the deliciousness values among all valid combinations.
inputFormat
The first line contains four integers: , , , and .
The second line contains integers, where the -th integer represents , the deliciousness value of the -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 .
sample
4 2 1 2
1 2 3 4
4 7