# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165476 | Sensei | Cipele (COCI18_cipele) | C++17 | 109 ms | 4056 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 MAXN = 1e5;
bool check (deque<int> a, deque<int> b, int val) {
if (a.size() > b.size()) {
swap(a, b);
}
for (int i = 0; i < a.size(); i++) {
while (b.size() > 0 && abs(b[0] - a[i]) > val) {
b.pop_front();
}
if (b.size() == 0) {
return false;
}
else {
b.pop_front();
}
}
return true;
}
int main () {
int N, M;
cin >> N >> M;
deque<int> a(N);
deque<int> b(M);
for (int i = 0; i < N; i++) {
scanf("%d", &a[i]);
}
sort(a.begin(), a.end());
for (int i = 0; i < M; i++) {
scanf("%d", &b[i]);
}
sort(b.begin(), b.end());
int ss = 0, se = 1e9;
int jump = 1;
while (ss + jump * 2 <= se) {
jump *= 2;
}
for (; jump > 0; jump /= 2) {
int mid = se - jump;
if (mid < ss) {
continue;
}
if (check(a, b, mid)) {
se = mid;
}
else {
ss = mid + 1;
}
}
cout << se << "\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... |