[VKOSHP 2024] Two Arrays
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
题目描述
Let the maximum in the array be denoted as and the minimum as .
Two arrays and of length are given. In one operation, you can choose an index and simultaneously increase the elements and by one: , . It is necessary to use these operations to achieve the simultaneous fulfillment of two conditions:
- ,
- .
Determine the minimum number of operations required to achieve the simultaneous fulfillment of the specified conditions, or find out that it is impossible.
输入格式
Each test consists of several test cases. The first line contains one integer --- the number of test cases (). The description of the test cases follows.
The first line of each test case contains three integers: , , (, ).
The second line of each test case contains integers --- the elements of array ().
The third line of each test case contains integers --- the elements of array ().
It is guaranteed that the sum of across all test cases does not exceed .
输出格式
For each test case, output one integer --- the minimum possible number of operations required to satisfy both conditions. If it is impossible to satisfy both conditions simultaneously, output .
5
4 2 3
-1 -2 -3 -4
-1 -2 -3 -4
3 3 2
1 6 4
1 4 1
4 0 3
0 2 1 2
0 2 3 3
5 2 1
-1 0 1 2 3
2 2 2 2 2
3 66 77
235 -111 9
100 -200 -100
1
3
3
-1
440
竞赛组 二分
- Status
- Done
- Rule
- IOI
- Problem
- 3
- Start at
- 2026-9-7 10:45
- End at
- 2026-9-7 12:45
- Duration
- 2 hour(s)
- Host
- Partic.
- 13