/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
#define tc int tttttt;cin>>tttttt;while(tttttt--)
#define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1])
bool isint(const string& s){
bool ok=1;
for(char i:s)
ok&=isdigit(i);
return ok;
}
bool isseq(const string& s){
return !isint(s);
}
int main(){
ACPLS();
int n,m;
cin>>n>>m;
int a[n];
for(auto&i:a)cin>>i;
multiset<int>b;
for(int i = 0; i < m; i++){
ll x;
cin>>x;
b.insert(x);
}
int lo=0,hi=1e9,ans=hi;
sort(a,a+n);
while(lo<=hi){
ll mid=(lo+hi)/2;
multiset<int>ms=b;
bool ok = 1;
for(int i = 0; i < n; i++){
if(ms.empty())break;
auto it = ms.lower_bound(a[i]-mid);
if(it==ms.end()||abs((*it)-a[i])>mid){
ok=0;
break;
}
ms.erase(it);
}
if(ok){
ans=mid;
hi=mid-1;
}else lo=mid+1;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
312 ms |
11460 KB |
Output is correct |
2 |
Correct |
486 ms |
11356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
448 ms |
11356 KB |
Output is correct |
2 |
Correct |
423 ms |
11460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
460 KB |
Output is correct |
2 |
Correct |
15 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
716 KB |
Output is correct |
2 |
Correct |
16 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
840 KB |
Output is correct |
2 |
Correct |
15 ms |
900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
836 KB |
Output is correct |
2 |
Correct |
15 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
844 KB |
Output is correct |
2 |
Correct |
15 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
667 ms |
11016 KB |
Output is correct |
2 |
Incorrect |
222 ms |
6752 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
471 ms |
10660 KB |
Output is correct |
2 |
Correct |
195 ms |
7412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
517 ms |
10456 KB |
Output is correct |
2 |
Incorrect |
328 ms |
9804 KB |
Output isn't correct |