# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646123 | Hacv16 | Cipele (COCI18_cipele) | C++17 | 46 ms | 4912 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;
#define pb push_back
#define sc second
#define fr first
#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define dbg(x) cerr << #x << ": [ " << x << " ]\n"
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 2e6 + 15;
const int INF = 0x3f3f3f3f;
ll n, m;
vector<ll> l, r;
bool f(ll x){
ll shoes = 0;
for(int i = 0, j = 0; i < n, j < m; i++, j++){
while(j < m && abs(r[j] - l[i]) > x) j++;
if(j != m) shoes++;
}
return shoes >= n;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 0; i < n; i++){
ll x; cin >> x; l.pb(x);
}
for(int i = 0; i < m; i++){
ll x; cin >> x; r.pb(x);
}
if(n > m) swap(l, r), swap(n, m); //always make l the smaller one
sort(all(l)); sort(all(r));
ll l = 0, r = INF, ans = INF;
while(l <= r){
ll mid = (l + r) >> 1;
if(f(mid)) ans = mid, r = mid - 1;
else l = mid + 1;
}
cout << ans << '\n';
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... |