SP10644 MYQ6 - Serve The Street
Description
Shree is a very ambitious person and wants to start a new company "RAM COURIER SERVICE" in the country of Thuvax. He plans to open his first office in the Main Street of Thuvax to serve only the people of this street. The Main Street is an inclined road consisting of N buildings spaced out unevenly(building 1 at lowest level and building N at highest level). The distance between adjacent buildings are known to Shree.
The delivery costs incurred by him for various deliveries are calculated as follows:
To deliver a package of weight 'w' to a building downhill at a distance 'd' from the office, Shree spends w\*d\*1 units of money.
To deliver a package of weight 'w' to a building uphill at a distance 'd' from the office, Shree spends w\*d\*2 units of money.
To deliver a package of non-zero weight to his own building, Shree spends 10 units of money irrespective of the weight of the package.
Shree being an astute businessman wants to choose one of these buildings for his new office so that the total delivery cost incurred by him is minimum.
Help Shree choose the building for his new office.
Input Format
The first line of the input consists of number of test cases t(1
Output Format
Output a single line for each test case containing two integers separated by a space.
The first integer is the minimum delivery cost and the next integer is the building number where the office should be placed in order to incur that cost.
If more than one building has the same minimum cost, print the building labelled with the smallest number.