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;
vector<int> A,B;
int N,M;
int guloso_match(int X){
int ptr = 0;
for(int i = 0;i<N;i++){
while(ptr < M && abs(A[i] - B[ptr]) > X ){
ptr++;
}
if(ptr >= M){
return 0;
}
else{
ptr++;
}
}
return 1;
}
int main(){
cin.tie(0);ios_base::sync_with_stdio(0);
cin >> N >> M;
for(int i = 0;i<N;i++){
int x;
cin >> x;
A.push_back(x);
}
for(int i = 0;i<M;i++){
int x;
cin >> x;
B.push_back(x);
}
if(N > M){
swap(A,B);
swap(N,M);
}
sort(A.begin(),A.end());
sort(B.begin(),B.end());
int ini = 0, fim = 1e9, meio,resp;
while(ini <= fim){
meio = ini + (fim - ini)/2;
if(guloso_match(meio)){
resp = meio;
fim = meio - 1;
}
else{
ini = meio + 1;
}
}
cout << resp << endl;
return 0;
}
Compilation message (stderr)
cipele.cpp: In function 'int main()':
cipele.cpp:63:10: warning: 'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]
cout << resp << endl;
^~~~
# | 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... |