Algorithm title: UVA 10201 Adventures in Moving

Source: Internet
Author: User

Problem A:adventures in Moving-part IV

To help with the move from Waterloo to the "Big city", you are considering renting a moving truck. Gas prices being so high this is the want to know how much of the gas for such a beast would set your back.

The truck consumes a full litre of gas for each kilometre it travels. It has a litre gas tank. When you rent the "Truck in Waterloo", the tank is half full. When you return it to the big city, the tank must is at least half full, or you'll get gouged even more for gas by the Ren Tal Company. You are would like to spend as little as possible in gas, but your don ' t want to run out along the way.

Input

The input begins with a single positive integer in a line by itself indicating the number of cases following, each of them as described below. This are followed by a blank line, and there are also a blank line between two consecutive.

The Input is all integers. The "the" the "distance in kilometres" is the "the" in most 10000. Next comes a set of "up to" gas station specifications, describing all the gas stations along your route, in Non-decreas ing order by distance. Each specification consists of the distance in kilometres of the gas station from Waterloo, and the price of a litre of GA s at the gas station, tenths of a cent, at most 2000.

Output

For each test case, the output must follow the description below. The outputs of two consecutive cases is separated by a blank line.

Output is the minimum amount of the ' you can spend ' to the If It isn't possible to the "Waterloo" to "the" "the" the "Constraints above, print" impossible ".

Sample Input

1
999
888
777 999 1009 450 1019
500 1399

Output for Sample Input

450550
Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.