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 endl '\n'
typedef long long ll;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int L,R; cin >> L >> R;
vector<int> LL;
vector<int> RR;
for(int i = 1; i <= L; i++) {
int x; cin >> x;
LL.push_back(x);
}
for(int i = 1; i <= R; i++) {
int x; cin >> x;
RR.push_back(x);
}
sort(LL.begin(),LL.end());
sort(RR.begin(),RR.end());
int Max = INT_MIN;
if(L > R) {
int leftptr = 0;
for(int i = 0; i < R; i++) {
while(abs(RR[i] - LL[leftptr]) > abs(RR[i] - LL[leftptr + 1])) leftptr++;
Max = max(Max,abs(RR[i] - LL[leftptr]));
}
}
else if(R > L) {
int leftptr = 0;
for(int i = 0; i < L; i++) {
while(abs(LL[i] - RR[leftptr]) > abs(LL[i] - RR[leftptr + 1])) leftptr++;
Max = max(Max,abs(LL[i] - RR[leftptr]));
}
}
else {
for(int i = 0; i < L; i++) {
Max = max(Max,abs(LL[i] - RR[i]));
}
}
cout << Max;
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... |