CF1530C Pursuit
题目描述
你和你的朋友伊利亚正在参加由多个阶段组成的编程竞赛。
对于每个阶段,你和伊利亚都会获得一个分数,保证为 $0$ 到 $100$ 之间的整数。并且,每个人获得的分数都是相互独立的,不受对方影响。
总分是这样计算的:设当前已进行 $k$ 个阶段,则你的总分为最高的 $k-\left\lfloor k\div4\right\rfloor $个阶段得分之和。其中 $\left\lfloor a\right\rfloor$ 代表 $a$ 向下取整(不大于 $a$ 的最大整数)。
现在,这个竞赛已进行了 $n$ 个阶段,你也知道这些阶段中,两个人获得的分数。但比赛仍在进行。请问:理论上,至少再过多少个阶段,你的总分才能超过伊利亚?如果你的总分已经超过了她,请输出 `0`。
输入格式
第一行一个整数 $t$($1\le t\le1000$),代表测试数据组数。
对于每个测试数据,第一行一个整数 $n$($1\le n\le10^5$),代表已经进行了 $n$ 个阶段。
接下来有两行,每行都有 $n$ 个数。第一行代表你的每个阶段的得分,第二行代表伊利亚每个阶段的得分。
输出格式
对于每个测试数据,输出一行,一个整数,即问题所求的答案。如果你的总分已经超过了她,请输出 `0`。
Translated by [dengzijun](https://www.luogu.com.cn/user/387836)
说明/提示
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.