#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
signed main(){
int n,m;
cin>>n>>m;
set<int>nums;
vector<int>sprinklers(n);
vector<int>flowers(m);
for(int i=0;i<n;i++)cin>>sprinklers[i];
for(int i=0;i<m;i++)cin>>flowers[i];
for(int i=0;i<n;i++)nums.insert(sprinklers[i]);
for(int i=0;i<m;i++)nums.insert(flowers[i]);
int maxdistance=-1;
if(n==1){
auto it1=nums.begin();
auto it2=nums.end();it2--;
if(sprinklers[0]!=*it1&&sprinklers[0]!=*it2){
cout<<-1;
return 0;
}
}
for(int i=0;i<n;i++){
int mindistance=LLONG_MAX;
for(int j=0;j<m;j++){
mindistance=min(mindistance,abs(sprinklers[i]-flowers[j]));
}
maxdistance=max(maxdistance,mindistance);
}
cout<<maxdistance;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct |
2 |
Incorrect |
32 ms |
3900 KB |
Unexpected end of file - token expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |