21505_Alibaba

2022-5-16 18:19| 发布者: Hocassian| 查看: 35| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505348116800-Problem List-采集的数据-后羿采集器.html

Pro.ID

21505

Title

Alibaba

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21505

AC

6

Submit

23

Ratio

26.09%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Alibaba the famous character of our childhood stories would like to be immortal in order to keep bringing happiness to children. In order to rich this status he needs to prove that he is still able to do some unusual things. There are n treasures, (n ≤ 10000) each in a different place located along a straight road.Each treasure has a time limit, after that it vanishes. Alibaba must take all the n treasures, and he must do it quickly. So he needs to figure out the order in which he should take the treasures before their deadlines starting from the most favorable position. Alibaba has the list of places and deadlines of the treasures.A place i is located at distance di from the leftmost end of the road. The time it takes to take a treasure is instantaneous. Alibaba must find the smallest time by which he can take all the treasures.

    输入

    Each data set in the input stands for a particular set of treasures. For each set of treasures the input contains the number of treasures, and the list of pairs place - deadline in increasing order of the locations. White spaces can occur freely between the numbers in the input.The input data are correct.

    输出

    Description

    Alibaba the famous character of our childhood stories would like to be immortal in order to keep bringing happiness to children. In order to rich this status he needs to prove that he is still able to do some unusual things. There are n treasures, (n ≤ 10000) each in a different place located along a straight road.Each treasure has a time limit, after that it vanishes. Alibaba must take all the n treasures, and he must do it quickly. So he needs to figure out the order in which he should take the treasures before their deadlines starting from the most favorable position. Alibaba has the list of places and deadlines of the treasures.A place i is located at distance di from the leftmost end of the road. The time it takes to take a treasure is instantaneous. Alibaba must find the smallest time by which he can take all the treasures.

    Input

    Each data set in the input stands for a particular set of treasures. For each set of treasures the input contains the number of treasures, and the list of pairs place - deadline in increasing order of the locations. White spaces can occur freely between the numbers in the input.The input data are correct.

    Output

    For each set of data the program prints the result to the standard output on a separate line. The solution is represented by the smallest time by which Alibaba can take all the treasures before they vanish. If this is not possible then the output is "No solution".

    Sample Input
    5
    1 3
    3 1
    5 8
    8 19
    10 15

    5
    1 5
    2 1
    3 4
    4 2
    5 3
    Sample Output
    11
    No solution
    Source

    样例输入

    5
    1 3
    3 1
    5 8
    8 19
    10 15

    5
    1 5
    2 1
    3 4
    4 2
    5 3

    样例输出

    11
    No solution

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部