欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1253A.Single Push
Single Push
You're given two arrays and , both of the same length .
In order to perform a push operation, you have to choose three integers satisfying and . Then, you will add to elements .
For example, if and you choose , the array will become .
You can do this operation at most once. Can you make array equal to array ?
(We consider that if and only if, for every , )
Input
The first line contains a single integer () — the number of test cases in the input.
The first line of each test case contains a single integer () — the number of elements in each array.
The second line of each test case contains integers ().
The third line of each test case contains integers ().
It is guaranteed that the sum of over all test cases doesn't exceed .
Output
For each test case, output one line containing "YES" if it's possible to make arrays and equal by performing at most once the described operation or "NO" if it's impossible.
You can print each letter in any case (upper or lower).
Note
The first test case is described in the statement: we can perform a push operation with parameters to make equal to .
In the second test case, we would need at least two operations to make equal to .
In the third test case, arrays and are already equal.
In the fourth test case, it's impossible to make equal to , because the integer has to be positive.
Samples
4
6
3 7 1 4 1 2
3 7 3 6 3 2
5
1 1 1 1 1
1 2 1 3 1
2
42 42
42 42
1
7
6
YES
NO
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |