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;
const int MAX_N = 3e5;
const int MAX_K = 1e9;
int f[MAX_N], b[MAX_N];
int main() {
int n, m;
cin >> n >> m;
for ( int i = 0; i < n; i++ )
cin >> f[i];
sort( f, f + n );
for ( int i = 0; i < m; i++ )
cin >> b[i];
sort( b, b + m );
if ( n > m ) {
swap( n, m );
swap( f, b );
}
int st = -1, dr = MAX_K;
while ( dr - st > 1 ) {
int k = (st + dr) / 2;
int j = 0;
for ( int i = 0; i < n; i++ ) {
while ( j < m && abs( f[i] - b[j] ) > k )
j++;
j++;
}
if ( j <= m )
dr = k;
else
st = k;
}
cout << dr << "\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... |