# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95551 | kimcoding | Cipele (COCI18_cipele) | C++17 | 33 ms | 2808 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector <int> vi;
int n, m, ans;
vi a, b;
bool function(int x) {
for (int i = 1, j = 1; i <= n; i++) {
while (j <= m && a[i] - b[j] > x) j++;
if (j > m || b[j] - a[i] > x) return false;
}
return true;
}
int main() {
scanf("%d %d", &n, &m);
a = vi(n + 1), b = vi(m + 1);
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(n, m), swap(a, b);
int left = 0, right = 1e9;
while (left <= right) {
int mid = (left + right) / 2;
if (function(mid)) {
ans = mid;
right = mid - 1;
}
else left = mid + 1;
}
printf("%d\n", ans);
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... |