CF993D.Compute Power

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.

You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task can be any, the second task on each computer must use strictly less power than the first. You will assign between 1 and 2 tasks to each computer. You will then first execute the first task on each computer, wait for all of them to complete, and then execute the second task on each computer that has two tasks assigned.

If the average compute power per utilized processor (the sum of all consumed powers for all tasks presently running divided by the number of utilized processors) across all computers exceeds some unknown threshold during the execution of the first tasks, the entire system will blow up. There is no restriction on the second tasks execution. Find the lowest threshold for which it is possible.

Due to the specifics of the task, you need to print the answer multiplied by 1000 and rounded up.

你需要执行若干任务,每个任务关联着其所需的处理器数量以及将消耗的计算能力。

你拥有足够数量的模拟计算机,每台计算机都具备足以处理任意任务的处理器数量。每台计算机一次最多只能执行一个任务,且总共最多执行两个任务。第一项任务可以是任意任务,但分配给每台计算机的第二项任务所消耗的计算能力必须严格小于该计算机上第一项任务所消耗的计算能力。每台计算机将被分配 1 或 2 个任务。随后,你将首先在所有计算机上并行执行各自的第一项任务;待所有第一项任务全部完成后,再在那些被分配了两个任务的计算机上并行执行各自的第二项任务。

在第一阶段(即所有第一项任务同时执行期间),若所有计算机上当前正在运行的任务所消耗的总计算能力除以当前正在使用的处理器总数(即:所有正在运行任务的功耗之和 ÷ 当前已启用的处理器总数)所得的平均每处理器计算能力超过了某个未知阈值,则整个系统将崩溃。第二阶段(执行第二项任务时)则无此限制。

请找出使得上述方案可行的最低阈值。

由于本题的特殊要求,你需将答案乘以 1000 后向上取整(ceiling)并输出。

输入格式

The first line contains a single integer n (1 ≤ n ≤ 50) — the number of tasks.

The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 108), where a__i represents the amount of power required for the i-th task.

The third line contains n integers _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ 100), where b__i is the number of processors that i-th task will utilize.

第一行包含一个整数 nn(1≤n≤501 \leq n \leq 50)—— 表示任务的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1081 \leq a_i \leq 10^8),其中 aia_i 表示第 ii 个任务所需的电量。

第三行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \ldots, b_n(1≤bi≤1001 \leq b_i \leq 100),其中 bib_i 表示第 ii 个任务将使用的处理器数量。

输出格式

Print a single integer value — the lowest threshold for which it is possible to assign all tasks in such a way that the system will not blow up after the first round of computation, multiplied by 1000 and rounded up.

输出一个整数——即能够以某种方式分配所有任务,使得系统在第一轮计算后不会崩溃的最低阈值,该阈值乘以 1000 后向上取整。

输入输出样例

  • 输入#1

    6
    8 10 9 9 8 10
    1 1 1 1 1 1

    输出#1

    9000
  • 输入#2

    6
    8 10 9 9 8 10
    1 10 5 5 1 10

    输出#2

    1160

说明/提示

In the first example the best strategy is to run each task on a separate computer, getting average compute per processor during the first round equal to 9.

In the second task it is best to run tasks with compute 10 and 9 on one computer, tasks with compute 10 and 8 on another, and tasks with compute 9 and 8 on the last, averaging (10 + 10 + 9) / (10 + 10 + 5) = 1.16 compute power per processor during the first round.

在第一个例子中,最优策略是将每个任务分别运行在一台独立的计算机上,使得第一轮中每台处理器的平均计算量为 9。

在第二个例子中,最优策略是将计算量为 10 和 9 的任务运行在一台计算机上,将计算量为 10 和 8 的任务运行在另一台计算机上,将计算量为 9 和 8 的任务运行在最后一台计算机上,从而在第一轮中获得每台处理器的平均计算能力为 (10+10+9)/(10+10+5)=1.16(10 + 10 + 9) / (10 + 10 + 5) = 1.16。

输入解题思路,AI测评打分。不知道怎么写?

首页