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;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int l,r;
cin >> l >> r;
vector <int> a, b;
for(int i = 0; i < l; i++){
int input;
cin >> input;
a.push_back(input);
}
for(int i = 0; i < r; i++){
int input;
cin >> input;
b.push_back(input);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(l < r){
int first = a[0];
auto pt = upper_bound(b.begin(), b.end(), first);
--pt;
int ind = (pt - b.begin());
while(ind + l > r) ind--;
int mx = 0;
for(int i = 0; i < l; i++){
mx = max(mx, abs(a[i] - b[i + ind]));
}
cout << mx;
}
else if(r < l){
int first = b[0];
auto pt = upper_bound(a.begin(), a.end(), first);
int ind = (pt - a.begin());
while(ind + r > l) ind--;
int mx = 0;
for(int i = 0; i < r; i++){
mx = max(mx, abs(b[i] - a[i + ind]));
}
cout << mx;
}
else{
int mx = 0;
for(int i = 0; i < l; i++){
mx = max(mx, abs(a[i] - b[i]));
}
cout << mx;
}
}
# | 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... |