atcoder#ARC139D. [ARC139D] Priority Queue 2
[ARC139D] Priority Queue 2
Score : points
Problem Statement
You are given a multiset of integers with elements: . It is guaranteed that every element of is between and (inclusive).
Let us repeat the following operation times.
- Choose an integer between and (inclusive) and add it to . Then, delete the -th smallest value in .
Here, the -th smallest value in is the -th value from the front in the sequence of the elements of sorted in non-decreasing order.
There are ways to choose an integer times between and . Assume that, for each of these ways, we have found the sum of the elements of after the operations with the corresponding choices. Find the sum, modulo , of the values computed.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 4 2 1
1 3
99
We start with . Here is an example of how we do the operations.
- Add to , making . Then, delete the -st smallest value, making .
- Add to , making . Then, delete the -st smallest value, making .
In this case, the sum of the elements of after the operations is .
5 9 6 3
3 7 1 9 9
15411789