atcoder#ARC125E. [ARC125E] Snack
[ARC125E] Snack
Score : points
Problem Statement
There are kinds of snacks numbered through . We have pieces of Snack .
There are children numbered through . We will distribute the pieces of snacks to these children. Here, all of the following conditions must be satisfied.
- For every kind of snack, Child gets at most pieces of that kind.
- Child gets at most pieces of snacks in total.
Find the maximum total number of pieces of snacks that can be distributed to the children under these conditions.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 3
2 5 5
1 2 2
5 3 5
11
The optimal distribution of snacks is as follows.
- Child gets , , piece of Snacks , , , respectively.
- Child gets , , piece(s) of Snacks , , , respectively.
- Child gets , , piece(s) of Snacks , , , respectively.
10 6
3 54 62 64 25 89 1 47 77 4
1 17 10 29 95 17
32 40 90 27 50 9
211