# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
973980 |
2024-05-02T14:11:38 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++14 |
|
25 ms |
2908 KB |
#include <bits/stdc++.h>
#define abs(x) (x < 0 ? -x : x)
int read(int x = 0, int f = 0, char ch = getchar())
{
while ('0' > ch or ch > '9')
f = ch == '-', ch = getchar();
while ('0' <= ch and ch <= '9')
x = x * 10 + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
const int N = 1e5 + 5;
int n, m, ans;
int a[N], b[N];
int judge(int x, int res = 0)
{
for (int i = 0, now = 0; i < n; i++)
{
while (now < m and b[now] < a[i] - x)
now++;
if (now < m and abs(b[now] - a[i]) <= x)
res++, now++;
}
return res;
}
int main()
{
n = read(), m = read();
for (int i = 0; i < n; i++)
a[i] = read();
for (int i = 0; i < m; i++)
b[i] = read();
std::sort(a, a + n), std::sort(b, b + m);
for (int L = 0, R = 1e9, mid; L <= R;)
if (judge(mid = (L + R) >> 1) == std::min(n, m))
ans = mid, R = mid - 1;
else
L = mid + 1;
return printf("%d", ans), 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
2648 KB |
Output is correct |
2 |
Correct |
23 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
2904 KB |
Output is correct |
2 |
Correct |
24 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2396 KB |
Output is correct |
2 |
Correct |
14 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2652 KB |
Output is correct |
2 |
Correct |
9 ms |
2000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2396 KB |
Output is correct |
2 |
Correct |
23 ms |
2552 KB |
Output is correct |