This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
vector<int>L,R;
main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
L.push_back(x);
}
for(int i=0;i<m;i++)
{
int x;
cin>>x;
R.push_back(x);
}
sort(L.begin(),L.end());
sort(R.begin(),R.end());
if(n>m)
{
swap(n,m);
swap(L,R);
}
int st=0,en=n-1;
int answer = 1e9;
while(en<=m-1)
{
int ans=0;
int j=st;
for(int i=0;i<n;i++)
{
int x = abs(L[i]-R[j]);
ans=max(ans,x);
j++;
}
answer = min(answer,ans);
st++;
en++;
}
cout<<answer<<endl;
}
Compilation message (stderr)
cipele.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |