Codeforces Round 488 by NEAR (Div. 1)
D
Compute Power
Codeforces
2500
原题
← CE →
翻译中…

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.

翻译中…

Input

翻译中…

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*} ≤ 10^{8}$), 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.

翻译中…

Output

翻译中…

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.

翻译中…

Note

翻译中…

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.

翻译中…

样例

Input #1
6
8 10 9 9 8 10
1 1 1 1 1 1
Output #1
9000
InputCopy OutputCopy
Input #2
6
8 10 9 9 8 10
1 10 5 5 1 10
Output #2
1160
InputCopy OutputCopy
题目信息
题号
993D
时间限制
1 s
内存限制
256 MB
标签
二分
动态规划
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。