# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199519 | ZwariowanyMarcin | Cipele (COCI18_cipele) | C++14 | 69 ms | 3216 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>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define LD long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);
using namespace std;
const int nax = 1e5 + 111;
int n, m, a;
vector <int> x, y;
bool ok(int dif) {
int wsk = 0;
for (int i = 0; i < ss(x); ++i) {
while (wsk < ss(y) && abs(x[i] - y[wsk]) > dif) wsk++;
if (wsk == ss(y)) return false;
wsk++;
}
return true;
}
int main() {
scanf ("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf ("%d", &a);
x.pb(a);
}
for (int i = 1; i <= m; ++i) {
scanf ("%d", &a);
y.pb(a);
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
if (ss(x) > ss(y)) swap(x, y);
int l = 0;
int r = 1e9 + 11;
while (l < r) {
int m = (l + r) / 2;
if (ok(m)) r = m;
else l = m + 1;
}
printf ("%d\n", l);
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... |