410295: GYM104003 C William and Middle Management
Description
William is employed at a local factory in his dream job: middle management.
Taking the assembly line to heart, the factory contains $$$N$$$ workers, who reside on a line. Each individual $$$i$$$ has a productivity $$$p_i$$$ and works $$$h_i$$$ hours. Their individual output is given by the product of these two values.
As he is the most senior middle manager, William gets the first pick of his team. William is expected to manage a team of $$$K$$$ people and his bonus is the total output of his managed workers, in dollars. Of course, the team must be contiguous to ensure sufficient team bonding.
Please help William determine the optimal team and more importantly, tell him what he truly cares about, his bonus.
InputThe first line contains two integers: $$$N$$$ and $$$K$$$ where $$$1 \leq K \leq N \leq 10^5$$$.
The next $$$N$$$ lines each contain two integers, $$$1 \leq p_i \leq 100$$$ and $$$1 \leq h_i \leq 100$$$.
OutputA single integer, William's optimal bonus.
ExampleInput4 2 2 3 1 3 3 2 4 1Output
10