# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473634 |
2021-09-15T18:47:11 Z |
rainboy |
Vrtić (COCI18_vrtic) |
C |
|
1 ms |
280 KB |
#include <stdio.h>
#define N 150
int max(int a, int b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
void sort(int *xx, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, x = xx[l + rand_() % (r - l)], tmp;
while (j < k)
if (xx[j] == x)
j++;
else if (xx[j] < x) {
tmp = xx[i], xx[i] = xx[j], xx[j] = tmp;
i++, j++;
} else {
k--;
tmp = xx[j], xx[j] = xx[k], xx[k] = tmp;
}
sort(xx, l, i);
l = k;
}
}
int main() {
static int pp[N], xx[N];
int n, i, ans;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &pp[i]);
for (i = 0; i < n; i++)
scanf("%d", &xx[i]);
sort(xx, 0, n);
if (n == 2)
ans = xx[1] - xx[0];
else {
ans = 0;
for (i = 2; i < n; i++)
ans = max(ans, xx[i] - xx[i - 2]);
}
printf("%d\n", ans);
for (i = 0; i < n; i += 2)
printf("%d ", xx[i]);
for (i = n % 2 == 0 ? n - 1 : n - 2; i >= 0; i -= 2)
printf("%d ", xx[i]);
printf("\n");
return 0;
}
Compilation message
vrtic.c: In function 'main':
vrtic.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
vrtic.c:38:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | scanf("%d", &pp[i]);
| ^~~~~~~~~~~~~~~~~~~
vrtic.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d", &xx[i]);
| ^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
280 KB |
the dissatisfaction value doesn't match with your answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
the dissatisfaction value doesn't match with your answer |
2 |
Halted |
0 ms |
0 KB |
- |