21492_FerryLoadingV

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

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

Pro.ID

21492

Title

Ferry Loading V

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Before bridges were common, ferries were used to transport vehicles across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Two lanes of vehicles drive onto the ferry from one end, the ferry crosses the river, and the vehicles exit from the other end of the ferry.

    The vehicles waiting to board the ferry form a single queue, and the operator directs each vehicle in turn to drive onto the port (left) or starboard (right) lane of the ferry so as to balance the load. Each vehicle in the queue has a different weight, which the operator estimates by inspecting the queue.

    Given n vehicles, you are to compute how to divide them between the port and starboard lanes so that the weight of vehicles on each side is nearly equal.

    输入

    Input contains several test cases. Each test case begins with 1 < n ≤ 100; the number of vehicles to be boarded. Consider the vehicles to be numbered 1 through n. n lines follow; the i-th line gives the weight in tonnes of the i-th vehicle -- a positive real number not greater than 100. A line containing 0 follows the last test case.

    输出

    Description

    Before bridges were common, ferries were used to transport vehicles across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Two lanes of vehicles drive onto the ferry from one end, the ferry crosses the river, and the vehicles exit from the other end of the ferry.

    The vehicles waiting to board the ferry form a single queue, and the operator directs each vehicle in turn to drive onto the port (left) or starboard (right) lane of the ferry so as to balance the load. Each vehicle in the queue has a different weight, which the operator estimates by inspecting the queue.

    Given n vehicles, you are to compute how to divide them between the port and starboard lanes so that the weight of vehicles on each side is nearly equal.

    Input

    Input contains several test cases. Each test case begins with 1 < n ≤ 100; the number of vehicles to be boarded. Consider the vehicles to be numbered 1 through n. n lines follow; the i-th line gives the weight in tonnes of the i-th vehicle -- a positive real number not greater than 100. A line containing 0 follows the last test case.

    Output

    For each test case, output a single line giving the numbers of the vehicles that should be directed to the starboard lane. Assume that the other vehicles will be directed to the port lane. The total weight of vehicles on the port side should not differ from that on the starboard side by more than 2%. If there are many solutions, any one will do. There will always be a solution; indeed, there will always be a solution that balances within 1%, but you aren't required to find it.

    Sample Input

    5
    10.0
    50.0
    90.0
    38.0
    7.1
    0

    Sample Output

    3 5

    Source

    样例输入

    5
    10.0
    50.0
    90.0
    38.0
    7.1
    0

    样例输出

    3 5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部