#P2637. [USACO08NOV] 第一次,第二次,成交!Going Once, Going Twice, Gone! B
[USACO08NOV] 第一次,第二次,成交!Going Once, Going Twice, Gone! B
Description
Because of the cows’ dieting campaign, FJ has a large amount of leftover hay he cannot use, so he plans to hold an auction to sell it.
He has batches of hay. He has customers, all of whom are farmers like him. Farmer says he will pay for each batch of FJ’s hay. Every farmer wants to buy exactly one batch (and only one).
To make sure the farmers do not envy each other, FJ decides to sell at a single fixed price. Every farmer whose bid is greater than or equal to FJ’s asking price will buy a batch.
Please help FJ find the lowest per-batch price that earns him the maximum total revenue.
Input Format
- The first line contains two integers and separated by a space.
- Lines through : line contains a single integer .
Output Format
Output one line with two space-separated integers: the lowest per-batch price FJ should set, and the maximum total revenue he can earn.
5 4
2
8
10
7
7 21
Hint
Sample Explanation
FJ has batches of hay, and farmers want to buy. Their bids per batch are , , , and .
FJ should set the price to . Then farmers will buy, and FJ will earn .
Constraints
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号