# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85224 | 2018-11-19T00:03:37 Z | FutymyClone | Cipele (COCI18_cipele) | C++14 | 100 ms | 12308 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, a[N], b[N]; bool check (int mid, bool small) { if (!small) { int pt = 1; for (int i = 1; i <= n; i++) { while (pt <= m && b[pt] < a[i] - mid) pt++; if (pt > m || b[pt] > a[i] + mid) return false; pt++; } } else { int pt = 1; for (int i = 1; i <= m; i++) { while (pt <= n && a[pt] < b[i] - mid) pt++; if (pt > n || a[pt] > b[i] + mid) return false; pt++; } } return true; } 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]); sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); if (n <= m) { int l = 0, r = 1e9; while (l <= r) { int mid = (l + r) / 2; if (check(mid, 0)) r = mid - 1; else l = mid + 1; } printf("%d", l); } else { int l = 0, r = 1e9; while (l <= r) { int mid = (l + r) / 2; if (check(mid, 1)) r = mid - 1; else l = mid + 1; } printf("%d", l); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 2784 KB | Output is correct |
2 | Correct | 56 ms | 4668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 100 ms | 6340 KB | Output is correct |
2 | Correct | 59 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8020 KB | Output is correct |
2 | Correct | 5 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8020 KB | Output is correct |
2 | Correct | 4 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8020 KB | Output is correct |
2 | Correct | 5 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 8020 KB | Output is correct |
2 | Correct | 5 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8020 KB | Output is correct |
2 | Correct | 4 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 8020 KB | Output is correct |
2 | Correct | 35 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 8428 KB | Output is correct |
2 | Correct | 27 ms | 9404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 10872 KB | Output is correct |
2 | Correct | 48 ms | 12308 KB | Output is correct |