#P11854. [CSP-J 2022 山东] 宴会
[CSP-J 2022 山东] 宴会
Background
Due to the pandemic, Shandong Province canceled the CSP-J 2022 certification event, and in March of the following year it set new problems and held a make-up contest within the province.
Problem Description
People today do not see the moon of ancient times, yet today’s moon once shone on people of old. Dreaming back to Chang’an, the grandeur of the Tang Dynasty, ten miles of Chang’an flowers, all seen in a single day.
Tang Chang’an was the largest city in the world at that time, with the most magnificent buildings and the most standardized planning layout. The characteristics of its construction system and planning layout included an unprecedented scale, the creation of the Imperial City, three-layer ring structure, use of six slopes, symmetrical layout, wide streets, neatly arranged wards, uniform design, crisscrossing canals, trees shading the city, and suburban ritual altars. The so-called Ten-mile Chang’an Street lay on the central axis of Chang’an, namely the Zhuque Avenue of Tang Chang’an, also known as Chengtianmen Avenue. Officials of the Tang Dynasty lived in various “wards”, and they had to pass through Zhuque Avenue when going to and returning from court.
To maintain connections and friendship among major families, officials would often hold a banquet once a month. For convenience, we view Zhuque Avenue as a number line, and each official’s ward is simplified to a coordinate point on the number line. They decide to choose a location (a point on the number line, not necessarily one of the coordinate points) to hold the banquet. Since the Tang Dynasty had strict curfews and everyone wanted the communication time to be as long as possible, they want the banquet to start as early as possible. Also, because the Tang Dynasty valued etiquette, each official will spend some time dressing up before going to the banquet location (also not necessarily a coordinate point).
More specifically, on a vertical street (equivalent to a one-dimensional coordinate), there are people living. Person lives at position (a non-negative integer) on the number line (a coordinate point). Every month they will choose to hold the banquet at (a point on the number line, not necessarily a coordinate point).
It is known that person needs time to travel from to the banquet location . In addition, they need time to dress up. In other words, they need a total time of to arrive at the banquet location.
Assume the initial time is . These people start dressing up and then set off for the banquet. They want the banquet to start as early as possible, so they ask for your help. Please help them determine the optimal banquet location .
Note: denotes the absolute value of the difference between and , and the home coordinates of the people in this problem are all integers.
Input Format
The first line contains a positive integer , indicating the number of testdata groups.
Then for each group of testdata (note: each group has lines of data, for a total of lines below):
The first line contains a positive integer , indicating the total number of officials.
The second line contains non-negative integers , representing the coordinates of these people on the number line.
The third line contains non-negative integers , representing the dressing-up time before departure for each person.
Output Format
Output lines in total. For each group of testdata, output one line with a real number (if it is an integer, output it as an integer; if it has decimals, output it with decimal place), representing the optimal location coordinate that makes the banquet start time as early as possible. (Clearly, is unique.)
7
1
0
3
2
3 1
0 0
2
1 4
0 0
3
1 2 3
0 0 0
3
1 2 3
4 1 2
3
3 3 3
5 3 3
6
5 4 7 2 10 4
3 2 5 1 4 6
0
2
2.5
2
1
3
6
Hint
Sample Explanation
The initial time is .
For the first group of testdata, there is only person, with coordinate and dressing-up time . Obviously, should be set at coordinate , making the banquet start time , which is the earliest.
For the second group of testdata, there are people with coordinates and , and both have dressing-up time . Obviously, should be set at coordinate , making the banquet start time , which is the earliest.
For the third group of testdata, there are people with coordinates and , and both have dressing-up time . Obviously, should be set at coordinate , making the banquet start time , which is the earliest.
Constraints
For of the data, .
For of the data, .
For of the data, $1\le T\le10^{3},n\le10^{5},0\le x_{i},t_{i}\le10^{8}$, and it is guaranteed that the sum of over all testdata does not exceed .
Translated by ChatGPT 5