#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
int n,m;
cin>>n>>m;
vector <int> v1(n);
vector <int> v2(m);
for(auto &i:v1) cin>>i;
for(auto &i:v2) cin>>i;
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
if(n<m){
ll ANS = 1e18;
for(int i=0;i<m-(n-1);i++){
ll cnt = 0;
ll ans = 0;
for(int j=i;j<n+i;j++){
ans = max((ll)abs(v2[j]-v1[cnt++]),ans);
}
ANS = min(ANS,ans);
}
cout<<ANS<<endl;
}
else {
ll ANS = 1e18;
for(int i=0;i<n-(m-1);i++){
ll cnt = 0;
ll ans = 0;
for(int j=i;j<m+i;j++){
ans = max((ll)abs(v1[j]-v2[cnt++]),ans);
}
ANS = min(ANS,ans);
}
cout<<ANS<<endl;
}
}
int main()
{
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
1068 KB |
Output is correct |
2 |
Correct |
108 ms |
1064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
972 KB |
Output is correct |
2 |
Correct |
100 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
6 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |