欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1833B.Restore the Weather
Restore the Weather
You are given an array containing the weather forecast for Berlandia for the last days. That is, — is the estimated air temperature on day ().
You are also given an array — the air temperature that was actually present on each of the days. However, all the values in array are mixed up.
Determine which day was which temperature, if you know that the weather never differs from the forecast by more than degrees. In other words, if on day the real air temperature was , then the equality is always true.
For example, let an array = [] of length and be given and an array = []. Then, so that the value of corresponds to the air temperature on day , we can rearrange the elements of the array so: []. Indeed:
- On the st day, , is satisfied;
- On the nd day , is satisfied;
- On the rd day, , is satisfied;
- On the th day, , is satisfied;
- On the th day, , is satisfied.
Input
The first line of input data contains a single integer () — the number of test cases.
The description of the test cases follows.
The first line of each test case contains two integers () and () — the number of days and the maximum difference between the expected and actual air temperature on each day.
The second line of each test case contains exactly integers — elements of array ().
The third line of each test case contains exactly integers — elements of array ().
It is guaranteed that the sum of over all test cases does not exceed , and that the elements of array can always be rearranged so that the equality is true for all .
Output
On a separate line for each test case, output exactly numbers — the values of air temperature on each of the days in the correct order.
If there is more than one answer — output any of them.
Samples
3
5 2
1 3 5 3 9
2 5 11 2 4
6 1
-1 3 -2 0 -5 -1
-4 0 -1 4 0 0
3 3
7 7 7
9 4 8
2 2 5 4 11
0 4 -1 0 -4 0
8 4 9
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |