欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1321A.Contest for Robots
Contest for Robots
Polycarp is preparing the first programming contest for robots. There are problems in it, and a lot of robots are going to participate in it. Each robot solving the problem gets points, and the score of each robot in the competition is calculated as the sum of over all problems solved by it. For each problem, is an integer not less than .
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 in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot. However, if the values of will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?
Input
The first line contains one integer () — the number of problems.
The second line contains integers , , ..., (). means that the "Robo-Coder Inc." robot will solve the -th problem, means that it won't solve the -th problem.
The third line contains integers , , ..., (). means that the "BionicSolver Industries" robot will solve the -th problem, means that it won't solve the -th problem.
Output
If "Robo-Coder Inc." robot cannot outperform the "BionicSolver Industries" robot by any means, print one integer .
Otherwise, print the minimum possible value of , if all values of are set in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot.
Note
In the first example, one of the valid score assignments is . Then the "Robo-Coder" gets points, the "BionicSolver" — points.
In the second example, both robots get points, and the score distribution does not matter.
In the third example, both robots solve all problems, so their points are equal.
Samples
5
1 1 1 0 0
0 1 1 1 1
3
3
0 0 0
0 0 0
-1
4
1 1 1 1
1 1 1 1
-1
9
1 0 0 0 0 0 0 0 1
0 1 1 0 1 1 1 1 0
4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |