# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757278 | racsosabe | Cipele (COCI18_cipele) | C++14 | 52 ms | 2856 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;
const int N = 100000 + 5;
int n;
int m;
int a[N];
int b[N];
bool can(int L) {
int at = 1;
for(int i = 1; i <= n; i++) {
while(at <= m and b[at] < a[i] - L) at += 1;
if(at <= m and b[at] <= a[i] + L) {
at += 1;
continue;
}
return false;
}
return true;
}
void swap() {
for(int i = 1; i <= max(n, m); i++) swap(a[i], b[i]);
swap(n, m);
}
int main(){
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++) scanf("%d", a + i);
for(int i = 1; i <= m; i++) scanf("%d", b + i);
if(n > m) swap();
sort(a + 1, a + n + 1);
sort(b + 1, b + m + 1);
int lo = 0, hi = 1000000000;
while(lo < hi) {
int mi = lo + (hi - lo) / 2;
if(not can(mi)) lo = mi + 1;
else hi = mi;
}
printf("%d\n", lo);
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... |