# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
476224 |
2021-09-25T12:30:16 Z |
rainboy |
Cipele (COCI18_cipele) |
C |
|
78 ms |
2832 KB |
#include <stdio.h>
#include <string.h>
#define N 100000
#define M 100000
#define INF 0x3f3f3f3f
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
void sort(int *aa, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, a = aa[l + rand_() % (r - l)], tmp;
while (j < k)
if (aa[j] == a)
j++;
else if (aa[j] < a) {
tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
i++, j++;
} else {
k--;
tmp = aa[j], aa[j] = aa[k], aa[k] = tmp;
}
sort(aa, l, i);
l = k;
}
}
int solve(int *aa, int n, int *bb, int m, int d) {
int i, j;
for (i = 0, j = 0; i < n; i++, j++) {
while (j < m && aa[i] - bb[j] > d)
j++;
if (j == m || bb[j] - aa[i] > d)
return 0;
}
return 1;
}
int main() {
static int aa[N], bb[M], tt[N];
int n, m, i, j, lower, upper, tmp;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (j = 0; j < m; j++)
scanf("%d", &bb[j]);
if (n > m) {
memcpy(tt, aa, n * sizeof *aa), memcpy(aa, bb, m * sizeof *bb), memcpy(bb, tt, n * sizeof *tt);
tmp = n, n = m, m = tmp;
}
sort(aa, 0, n);
sort(bb, 0, m);
lower = -1, upper = INF;
while (upper - lower > 1) {
int d = (lower + upper) / 2;
if (solve(aa, n, bb, m, d))
upper = d;
else
lower = d;
}
printf("%d\n", upper);
return 0;
}
Compilation message
cipele.c: In function 'main':
cipele.c:49:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
cipele.c:51:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | scanf("%d", &aa[i]);
| ^~~~~~~~~~~~~~~~~~~
cipele.c:53:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | scanf("%d", &bb[j]);
| ^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
2500 KB |
Output is correct |
2 |
Correct |
60 ms |
2832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
2824 KB |
Output is correct |
2 |
Correct |
59 ms |
2800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
432 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2356 KB |
Output is correct |
2 |
Correct |
37 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
2548 KB |
Output is correct |
2 |
Correct |
31 ms |
2416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
2308 KB |
Output is correct |
2 |
Correct |
58 ms |
2796 KB |
Output is correct |