# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672851 | tvladm2009 | Cipele (COCI18_cipele) | C++14 | 55 ms | 3168 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 ll = long long;
bool check(int x, std::vector<int> left, std::vector<int> right) {
int ptr1 = 0, ptr2 = 0;
int cnt = 0;
while(ptr1 < left.size() && ptr2 < right.size()) {
if(abs(left[ptr1] - right[ptr2]) <= x) {
cnt++;
ptr1++;
ptr2++;
} else
ptr2++;
}
return (cnt == left.size());
}
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int n, m;
std::cin >> n >> m;
std::vector<int> x(n), y(m);
for(int i = 0;i < n; i++)
std::cin >> x[i];
for(int i = 0;i < m; i++)
std::cin >> y[i];
std::sort(x.begin(), x.end());
std::sort(y.begin(), y.end());
if(n > m) {
std::swap(n, m);
std::swap(x, y);
}
int from = 0, to = 1e9, result = 0;
while(from <= to) {
int mid = (from + to) / 2;
if(check(mid, x, y)) {
result = mid;
to = mid - 1;
} else
from = mid + 1;
}
std::cout << result;
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... |