CF1321A.Contest for Robots
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp is preparing the first programming contest for robots. There are n problems in it, and a lot of robots are going to participate in it. Each robot solving the problem i gets pi points, and the score of each robot in the competition is calculated as the sum of pi over all problems i solved by it. For each problem, pi is an integer not less than 1.
Two corporations specializing in problem-solving robot manufacturing, "Robo-Coder Inc." and "BionicSolver Industries", are going to register two robots (one for each corporation) for participation as well. Polycarp knows the advantages and flaws of robots produced by these companies, so, for each problem, he knows precisely whether each robot will solve it during the competition. Knowing this, he can try predicting the results — or manipulating them.
For some reason (which absolutely cannot involve bribing), Polycarp wants the "Robo-Coder Inc." robot to outperform the "BionicSolver Industries" robot in the competition. Polycarp wants to set the values of pi in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot. However, if the values of pi will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of pi over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?
Polycarp 正在筹备首届面向机器人的编程竞赛。本次比赛共有 n 道题目,将有大量机器人参赛。每台机器人解决第 i 题可获得 pi 分,而每台机器人在比赛中的总得分即为其所解出的所有题目 i 对应的 pi 值之和。对每道题 i,pi 是一个不小于 1 的整数。
两家专精于问题求解机器人制造的企业——“Robo-Coder Inc.” 和 “BionicSolver Industries”——也将各自派出一台机器人(每家公司一台)参赛。Polycarp 熟悉这两家公司所产机器人的优势与缺陷,因此对每道题,他都确切知道两台机器人是否能在比赛中成功解决它。基于这些信息,他可以尝试预测甚至操控比赛结果。
出于某种原因(该原因绝对不涉及贿赂),Polycarp 希望“Robo-Coder Inc.” 的机器人在比赛中严格胜过“BionicSolver Industries”的机器人。为此,Polycarp 希望为各题设定分值 pi,使得“Robo-Coder Inc.” 机器人的总分严格大于“BionicSolver Industries”机器人的总分。然而,若 pi 的取值过大,则显得十分可疑;因此 Polycarp 希望最小化所有题目中 pi 的最大值。你能帮助 Polycarp 确定题目分值的最小可能上界吗?
输入格式
The first line contains one integer n (1≤n≤100) — the number of problems.
The second line contains n integers r1, r2, ..., rn (0≤ri≤1). ri=1 means that the "Robo-Coder Inc." robot will solve the i-th problem, ri=0 means that it won't solve the i-th problem.
The third line contains n integers b1, b2, ..., bn (0≤bi≤1). bi=1 means that the "BionicSolver Industries" robot will solve the i-th problem, bi=0 means that it won't solve the i-th problem.
第一行包含一个整数 n(1≤n≤100)—— 表示问题的数量。
第二行包含 n 个整数 r1, r2, ..., rn(0≤ri≤1)。若 ri=1,表示“Robo-Coder Inc.”机器人将解决第 i 个问题;若 ri=0,则表示它不会解决第 i 个问题。
第三行包含 n 个整数 b1, b2, ..., bn(0≤bi≤1)。若 bi=1,表示“BionicSolver Industries”机器人将解决第 i 个问题;若 bi=0,则表示它不会解决第 i 个问题。
输出格式
If "Robo-Coder Inc." robot cannot outperform the "BionicSolver Industries" robot by any means, print one integer −1.
Otherwise, print the minimum possible value of i=1maxnpi, if all values of pi are set in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot.
如果“Robo-Coder Inc.”机器人在任何情况下都无法胜过“BionicSolver Industries”机器人,则输出一个整数 −1。
否则,输出 i=1maxnpi 的最小可能值,其中所有 pi 的取值需满足“Robo-Coder Inc.”机器人获得的总分严格大于“BionicSolver Industries”机器人。
输入输出样例
输入#1
5 1 1 1 0 0 0 1 1 1 1
输出#1
3
输入#2
3 0 0 0 0 0 0
输出#2
-1
输入#3
4 1 1 1 1 1 1 1 1
输出#3
-1
输入#4
9 1 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 1 0
输出#4
4
说明/提示
In the first example, one of the valid score assignments is p=[3,1,3,1,1]. Then the "Robo-Coder" gets 7 points, the "BionicSolver" — 6 points.
In the second example, both robots get 0 points, and the score distribution does not matter.
In the third example, both robots solve all problems, so their points are equal.
在第一个例子中,一种有效的分数分配方案是 p=[3,1,3,1,1]。此时,“Robo-Coder”获得 7 分,“BionicSolver”获得 6 分。
在第二个例子中,两个机器人均获得 0 分,因此分数分配无关紧要。
在第三个例子中,两个机器人均解决了所有题目,因此它们的得分相等。
输入解题思路,AI测评打分。不知道怎么写?