#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define double long double
#define ceil(x,y) (x/y)+(x%y!=0)*((double)(1.0*x/y)<0?0:1)
#define floor(x,y) (x/y)+(x%y!=0)*((double)(1.0a*x/y)<0?-1:0)
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e18;
int arr[100010],arr2[100010],n,m;
int check(int x){
int a=0,b=0;
while(a<n&&b<m){
if(abs(arr[a]-arr2[b])<=x)
a++,b++;
else
b++;
}
return a==n;
}
int binary(){
int s=0,e=1000000000;
while(s<e){
int mid=s+(e-s)/2;
if(check(mid))
e=mid;
else
s=mid+1;
}
return e;
}
in main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tc=1;
//cin>>tc;
while(tc--){
cin>>n>>m;
for(int i=0;i<n;i++){
if(m<n)
cin>>arr2[i];
else
cin>>arr[i];
}
for(int i=0;i<m;i++){
if(m<n)
cin>>arr[i];
else
cin>>arr2[i];
}
if(m<n)
swap(n,m);
sort(arr,arr+n);
sort(arr2,arr2+m);
cout<<binary()<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
1868 KB |
Output is correct |
2 |
Correct |
55 ms |
1856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
1860 KB |
Output is correct |
2 |
Correct |
56 ms |
1860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
1468 KB |
Output is correct |
2 |
Correct |
33 ms |
2164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
1688 KB |
Output is correct |
2 |
Correct |
29 ms |
2524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
1508 KB |
Output is correct |
2 |
Correct |
48 ms |
3160 KB |
Output is correct |