题目大意: 有n个人,每个人有自己的要穿衣服的时间,然后让你求一个地点x,使最晚到达这个地点的人的时间最短。
思路:首先每个人的时间如果为0时,那么这个地点肯定是最大值和最小值的和的一半(艹一开始没想到),但是因为现在有穿衣服的时间,那么在所有人穿衣服的这段时间里面,每个人都会尽可能的往里面走使整个区间缩小,然后直到所有人都穿好衣服,此时区间的最大值和最小值的和也就是我当前的位置。
那么我们就可以在最长的这个穿衣服的人的时间里面,每个人去缩短这个区间的最大值和最小值(用最长的时间-最短时间就是我可以走的时间),最后区间的最大值和最小值加起来除以二就好了。
/**
* ┏┓ ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃ ┃
* ┃ ━ ┃ ++ + + +
* ████━████+
* ◥██◤ ◥██◤ +
* ┃ ┻ ┃
* ┃ ┃ + +
* ┗━┓ ┏━┛
* ┃ ┃ + + + +Code is far away from
* ┃ ┃ + bug with the animal protecting
* ┃ ┗━━━┓ 神兽保佑,代码无bug
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛ + + + +
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛+ + + +
*/
#include<cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include<vector>
#include<queue>
#include<map>
#define sc_int(x) scanf("%d", &x)
#define sc_ll(x) scanf("%lld", &x)
#define pr_ll(x) printf("%lld", x)
#define pr_ll_n(x) printf("%lld\n", x)
#define pr_int_n(x) printf("%d\n", x)
#define ll long long
using namespace std;
const int N=1000000+100;
int n ,m,h;
ll s[N],ss[N];
int main()
{
int t;
sc_int(t);
while(t--)
{
ll Maxn=0;
sc_int(n);
for(int i=1;i<=n;i++)sc_int(s[i]);
for(int i =1;i<=n;i++)
{
sc_int(ss[i]);
Maxn=max(ss[i],Maxn);
}
ll MAX=0x3f3f3f3f,MIN=0;
for(int i =1;i<=n;i++)
{
MIN=max(MIN,s[i]-(Maxn-ss[i]));
MAX=min(MAX,s[i]+(Maxn-ss[i]));
}
printf("%.7lf\n",(MAX+MIN)/2.0);
}
return 0;
}