atcoder#ABC151E. [ABC151E] Max-Min Sums
[ABC151E] Max-Min Sums
Score : points
Problem Statement
For a finite set of integers , let .
Given are integers .
We will choose of them and let be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are ways to make this choice. Find the sum of over all those ways.
Since the answer can be enormous, print it .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer .
4 2
1 1 3 4
11
There are six ways to choose : (we distinguish the two s). The value of for these choices are , respectively, for the total of .
6 3
10 10 10 -10 -10 -10
360
There are ways to choose . In of them, , and in of them, .
3 1
1 1 1
0
10 6
1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0
999998537
Print the sum .