This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define INF 1e10
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;
i64 N, M;
i64 a[MAX];
i64 b[MAX];
bool canDo( i64 x )
{
i64 cnt = 1;
for( i64 i = 1; i <= N; i ++ )
{
while( cnt <= M && abs( b[cnt] - a[i] ) > x )
cnt++;
if( cnt > M )
return false;
cnt++;
}
return true;
}
int main()
{
optimiza_io
cin >> N >> M;
if( N < M )
{
for( i64 i = 1; i <= N; i ++ )
cin >> a[i];
for( i64 i = 1; i <= M; i ++ )
cin >> b[i];
}
else
{
for( i64 i = 1; i <= N; i ++ )
cin >> b[i];
for( i64 i = 1; i <= M; i ++ )
cin >> a[i];
swap( N , M );
}
sort( a + 1 , a + N + 1 );
sort( b + 1 , b + M + 1 );
i64 ini = 0;
i64 fin = INF;
while( ini < fin )
{
i64 mid = ( ini + fin ) / 2;
if( canDo( mid ) )
fin = mid;
else
ini = mid + 1;
}
cout << ini << "\n";
return 0;
}
# | 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... |