atcoder#ARC137E. [ARC137E] Bakery
[ARC137E] Bakery
Score : points
Problem Statement
Snuke runs a bakery. He is planning for the next days. Let us call these days Day .
At the moment, the bakery hires nobody. There are bakers that Snuke can hire, numbered to .
yen must be paid to hire Baker . If Baker is hired, they will work on Day , baking one loaf of bread each day.
For each (), there is a limit to the number of loaves of bread that can be sold on Day . If loaves of bread are baked on Day , loaves will be sold on that day.
Each loaf of bread sold will yield a profit of yen.
Snuke wants to choose the set of bakers to hire to maximize the final profit: The total number of loaves soldThe total cost of hiring bakers. Find the maximum possible value of this.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
7 4 3
1 1 1 1 1 1 1
1 2 3
2 4 5
4 6 3
6 7 1
11
Snuke should hire Baker . In this case, the total cost to hire bakers is , and the number of loaves baked on Day will be , respectively. A total of loaves will be sold, for a final profit of .
3 1 5
1 1 1
2 2 10
0
It is optimal to hire no baker.
10 10 42
6 5 1 5 2 4 2 7 10 9
3 4 4
3 7 136
9 9 14
2 7 152
3 3 33
2 4 100
3 3 38
1 10 28
3 5 66
8 8 15
543