Exploring Undiscovered Planets
All submissions for this problem are available.You took a space craft on rent to visit Planet Stipi. On the way to Stipi, you decided to visit $N$ planets (numbered from $1$ to $N$) on the way to the destination (1st place being the source of your journey and Nth place being your destination). The spacecraft has a fuel tank of capacity 1L, so it needs regular refills. Every planet has a fuel station but the price of fuel is different over all the planets ($A_i$), also every planet is 1 km away from each other. There is a strange tradition on every petrol pump to get your fuel tank empty before getting it filled (The petrol pump will fill only 1 Litre, if the bike already contains some petrol, it needs to emptied). The spacecraft gives a mileage of $K$ kmpL. Since you are very bad at planning trips but extremely proficient in writing code, you decided to write a program that could efficiently plan your trip. Since its end of the month and you have already spent your money on various things. So, the program should print the minimum cost of the trip i.e. the total money to be spent on fuel. Initially, the fuel tank is empty. ###INPUT - First line contains two integers N and K. - Second line contains N spaced integers- Ai denoting the cost of fuel in ith spacecraft. ###OUTPUT - The only line of output contains a single integer, denoting the minimum cost. ###CONSTRAINTS - 1<=N<=1000000 - 1<=K<=10000 - 1<=Ai<=1000 ###SAMPLE INPUT 5 3 1 2 3 4 5 ###SAMPLE OUTPUT 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.