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 i = 0, j = 0;
while ( i < n && j < m ) {
if ( f[i] < b[j] ) {
if ( b[j] - f[i] <= k )
j++;
i++;
} else {
if ( f[i] - b[j] <= k )
i++;
j++;
}
}
if ( i == n )
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... |