# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146179 | fabjanm | Cipele (COCI18_cipele) | C++98 | 179 ms | 3240 KiB |
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<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int n,m;
vector<int>lef;
vector<int>righ;
void input(){
cin>>n>>m;
int br;
for(int i=0;i<n;i++){
cin>>br;
lef.push_back(br);
}
for(int i=0;i<m;i++){
cin>>br;
righ.push_back(br);
}
//cout<<lef.size()<<" "<<righ.size()<<endl;
}
bool prov(int ruz){
if(lef.size()<=righ.size()){
int pos=0;
for(int i=0;i<righ.size();i++){
//cout<<pos<<" -----> "<<lef[pos]<<" "<<righ[i]<<endl;
if(pos==lef.size())return true;
if(abs(lef[pos]-righ[i])<=ruz)pos++;
}
if(pos!=lef.size())return false;
else return true;
}
else{
int pos=0;
for(int i=0;i<lef.size();i++){
if(pos==righ.size())return true;
if(abs(righ[pos]-lef[i])<=ruz)pos++;
}
if(pos!=righ.size())return false;
else return true;
}
}
void solve(){
sort(lef.begin(),lef.end());
sort(righ.begin(),righ.end());
int lo=0,hi=1000000000;
while(lo<hi){
int mid=(lo+hi)/2;
///cout<<mid<<"->>>>>>>>"<<endl;
if(prov(mid)){
hi=mid;
}
else{
lo=mid+1;
}
//cout<<lo<<" --> "<<hi<<endl<<endl;
}
cout<<lo;
}
int main(){
input();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |