# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150866 | 2019-09-01T09:19:36 Z | pichulia | Cipele (COCI18_cipele) | C++11 | 59 ms | 2496 KB |
#include <stdio.h> #include <stdlib.h> #include<algorithm> using namespace std; int n, m; int a[100009]; int b[100009]; bool able(int x) { int skip = m - n; int i, j; for (i = j = 0; i < n && j < m && skip >= 0;) { if (a[i] >= b[j] - x && a[i] <= b[j] + x) { i++; j++; } else if (a[i] < b[j] - x) return false; else { j++; skip--; } } return i == n; } int main() { int i, j, k; scanf("%d %d", &n, &m); for (i = 0; i < n; i++)scanf("%d", &a[i]); for (i = 0; i < m; i++)scanf("%d", &b[i]); sort(a, a + n); sort(b, b + m); if (n > m) { for (i = 0; i < n; i++) { k = a[i]; a[i] = b[i]; b[i] = k; } k = n; n = m; m = k; } int l, r; l = 0; r = 1000000009; while (l < r) { int mid = (l + r) / 2; if (able(mid)) { r = mid; } else l = mid + 1; } printf("%d\n", l); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 1016 KB | Output is correct |
2 | Correct | 59 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 1116 KB | Output is correct |
2 | Correct | 59 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 552 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 380 KB | Output is correct |
2 | Correct | 4 ms | 484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 892 KB | Output is correct |
2 | Correct | 36 ms | 1712 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 1128 KB | Output is correct |
2 | Correct | 28 ms | 2040 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 888 KB | Output is correct |
2 | Correct | 52 ms | 2496 KB | Output is correct |