1 条题解
-
0
很史的特判
#include<bits/stdc++.h> using namespace std; #define int long long const int N=1e5+10; int s[N],t[N],inf; signed main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int a,b,q;cin>>a>>b>>q;inf=(1ll<<60); for(int i=1;i<=a;i++)cin>>s[i]; for(int i=1;i<=b;i++)cin>>t[i]; sort(s+1,s+a+1);sort(t+1,t+b+1); while(q--) { int x;cin>>x; int id1=lower_bound(s+1,s+a+1,x)-s-1; int id2=lower_bound(t+1,t+b+1,x)-t-1; int s1=(id1==0||id2==b)?inf:(x-s[id1]+t[id2+1]-x+min(x-s[id1],t[id2+1]-x)); int s2=(id1==0||id2==0)?inf:max(x-s[id1],x-t[id2]); int s3=(id1==a||id2==0)?inf:s[id1+1]-x+x-t[id2]+min(s[id1+1]-x,x-t[id2]); int s4=(id1==a||id2==b)?inf:max(s[id1+1]-x,t[id2+1]-x); cout<<min(min(s1,s2),min(s3,s4))<<'\n'; } return 0; }
- 1
信息
- ID
- 11627
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 8
- 标签
- 递交数
- 18
- 已通过
- 7
- 上传者