|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||35||22||22||62.857%|
You are very happy, that you got a job at ACME Corporation’s CPU factory. After a hard month of labor, your boss has given you c identical CPUs as payment. Apparently, ACME Corporation is low on cash at the moment.
Since you can’t live on CPUs alone, you want to sell them on the market and buy living essentials from the money you make. Unfortunately, the market is very restrictive in the way you are allowed to conduct business. You are only allowed to enter the market once, you can only trade with each merchant once, and you have to visit the traders in a specific order. The market organizers have marked each merchant with a number from 1 to m (the number of merchants) and you must visit them in this order. Each trader has his own price for every amount of CPUs to buy.
The input consists of:
Output the maximum amount of money you can make by selling the CPUs you have.
Note that you don’t have to sell all CPUs.
5 3 1 4 10 1 1 1 1 8 1 1 1 1 9 1 1