CF1530C.Pursuit
普及-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between 0 and 100 points, inclusive, for each stage, independently of other contestants.
Points received by contestants in different stages are used for forming overall contest results. Suppose that k stages of the contest are completed. For each contestant, k−⌊4k⌋ stages with the highest scores are selected, and these scores are added up. This sum is the overall result of the contestant. (Here ⌊t⌋ denotes rounding t down.)
For example, suppose 9 stages are completed, and your scores are 50,30,50,50,100,10,30,100,50. First, 7 stages with the highest scores are chosen — for example, all stages except for the 2-nd and the 6-th can be chosen. Then your overall result is equal to 50+50+50+100+30+100+50=430.
As of now, n stages are completed, and you know the points you and Ilya got for these stages. However, it is unknown how many more stages will be held. You wonder what the smallest number of additional stages is, after which your result might become greater than or equal to Ilya's result, at least in theory. Find this number!
你和你的朋友伊利亚正在参加一场包含多个阶段的个人编程竞赛。每位参赛者在每个阶段可获得 0 到 100 分(含端点)之间的任意整数分,且各参赛者在不同阶段的得分相互独立。
不同阶段的得分用于计算参赛者的总成绩。假设竞赛目前已完成 k 个阶段。对每位参赛者,选取其得分最高的 k−⌊4k⌋ 个阶段的得分(⌊t⌋ 表示对 t 向下取整),并将这些分数相加,所得和即为该参赛者的总成绩。
例如,假设目前已完成 9 个阶段,你的得分为 50,30,50,50,100,10,30,100,50。首先选出得分最高的 7 个阶段(因为 9−⌊49⌋=9−2=7)——例如,可排除第 2 阶段和第 6 阶段。那么你的总成绩为 50+50+50+100+30+100+50=430。
截至目前,已完成了 n 个阶段,且你已知自己和伊利亚在这些阶段中的得分。但尚不清楚后续还将进行多少个阶段。你想知道:至少还需增加多少个阶段,才有可能(理论上)使你的总成绩大于或等于伊利亚的总成绩? 请找出这个最小的额外阶段数!
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000). Description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤105) — the number of completed stages.
The second line contains n integers a1,a2,…,an (0≤ai≤100) — your points for the completed stages.
The third line contains n integers b1,b2,…,bn (0≤bi≤100) — Ilya's points for the completed stages.
It is guaranteed that the sum of n over all test cases does not exceed 105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤1000)。随后是测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤105)——已完成关卡的数量。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤100)——你在各已完成关卡中获得的分数。
第三行包含 n 个整数 b1,b2,…,bn(0≤bi≤100)——Ilya 在各已完成关卡中获得的分数。
保证所有测试用例的 n 之和不超过 105。
输出格式
For each test case print a single integer — the smallest number of additional stages required for your result to be able to become greater than or equal to Ilya's result.
If your result is already not less than Ilya's result, print 0.
对于每个测试用例,输出一个整数——使你的结果能够大于或等于伊利亚的结果所需的最少额外关卡数。
如果你的结果已经不小于伊利亚的结果,则输出 0。
输入输出样例
输入#1
5 1 100 0 1 0 100 4 20 30 40 50 100 100 100 100 4 10 20 30 40 100 100 100 100 7 7 59 62 52 27 31 55 33 35 50 98 83 80 64
输出#1
0 1 3 4 2
说明/提示
In the first test case, you have scored 100 points for the first stage, while Ilya has scored 0. Thus, your overall result (100) is already not less than Ilya's result (0).
In the second test case, you have scored 0 points for the first stage, while Ilya has scored 100. A single stage with an opposite result is enough for both your and Ilya's overall scores to become equal to 100.
In the third test case, your overall result is 30+40+50=120, while Ilya's result is 100+100+100=300. After three additional stages your result might become equal to 420, while Ilya's result might become equal to 400.
In the fourth test case, your overall result after four additional stages might become equal to 470, while Ilya's result might become equal to 400. Three stages are not enough.
在第一个测试用例中,你在第一阶段获得了 100 分,而伊利亚获得了 0 分。因此,你的总分(100)已经不小于伊利亚的总分(0)。
在第二个测试用例中,你在第一阶段获得了 0 分,而伊利亚获得了 100 分。只需再进行一个结果相反的阶段,你和伊利亚的总分均可达到 100。
在第三个测试用例中,你的总分为 30+40+50=120,而伊利亚的总分为 100+100+100=300。经过额外的三个阶段后,你的总分可能达到 420,而伊利亚的总分可能达到 400。
在第四个测试用例中,经过额外的四个阶段后,你的总分可能达到 470,而伊利亚的总分可能达到 400。三个阶段是不够的。
输入解题思路,AI测评打分。不知道怎么写?