# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472516 | HossamHero7 | Cipele (COCI18_cipele) | C++14 | 154 ms | 2476 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int n,m;
vector <int> v1;
vector <int> v2;
bool valid(int dif){
int curStart = 0;
for(int i=0;i<n;i++){
int idx = lower_bound(v2.begin()+curStart,v2.end(),v1[i]-dif) - v2.begin();
if(idx == m) return 0;
if(abs(v2[idx] - v1[i]) > dif) return 0;
curStart = idx + 1;
}
return 1;
}
void solve(){
cin>>n>>m;
v1.resize(n);
v2.resize(m);
for(auto &i:v1) cin>>i;
for(auto &i:v2) cin>>i;
if(n>m){
swap(n,m);
swap(v1,v2);
}
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
int l=0;
int r=1e9;
int ans=0;
while(l<=r){
int md = l + r >> 1;
if(valid(md)){
ans = md;
r = md - 1;
}
else l = md + 1;
}
cout<<ans<<endl;
}
int main()
{
int t=1;
// cin>>t;
while(t--){
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... |