Energija
Manufactering and optimal controlling the energy manufacturing is very important to every society. There is a prediction that Bosnia & Herzegovina will for 10 years from now have thousands of different power plants. People will build parks of new hydro and wind power plants by the existing thermal power plants. Every power plant can work with full capacity and every other capacity that is bigger than zero.
Electrical energy is hard to store so it is needed to manufacture only enough to satisfy the need for it.
Your task is to write a program that will for given electricity demand in one day and for given list of electric power plants with their maximum electrical energy producing and the price of producing find the cheapest manufactering plan.
Input
5
21
5 4
7 3
8 5
4 5
1 6Output
86Input
3
13
2 1
7 3
8 4Output
39Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.