#include <stdio.h>
#define MAXN 100100
#define update_min() while(used[++minimum])
#define update_max() while(used[--maximum])
int main(void) {
static int n, a[MAXN], b[MAXN];
static bool used[2 * MAXN];
scanf("%d", &n);
int minimum = 0, maximum = 2 * n;
used[2 * n] = true;
used[0] = true;
for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
a[1] = b[1];
for(int i = 2; i <= n; i++) {
if(b[i] == b[i - 1]) {
update_min();
a[2 * i - 2] = minimum, used[minimum] = true;
update_max();
a[2 * i - 1] = maximum, used[maximum] = true;
}
if(b[i] > b[i - 1]) {
if(used[b[i]] == false) {
a[2 * i - 2] = b[i];
used[b[i]] = true;
update_max();
a[2 * i - 1] = maximum, used[maximum] = true;
} else {
update_max();
a[2 * i - 2] = maximum, used[maximum] = true;
update_max();
a[2 * i - 1] = maximum, used[maximum] = true;
}
}
if(b[i] < b[i - 1]) {
if(used[b[i]] == false) {
a[2 * i - 2] = b[i], used[b[i]] = true;
update_min();
a[2 * i - 1] = minimum, used[minimum] = true;
} else {
update_min();
a[2 * i - 2] = minimum, used[minimum] = true;
update_min();
a[2 * i - 1] = minimum, used[minimum] = true;
}
}
}
printf("%d", a[1]);
for(int i = 2; i <= n; i++) printf(" %d", a[i]);
return 0;
}
Compilation message
medians.c: In function 'main':
medians.c:7:9: error: unknown type name 'bool'
static bool used[2 * MAXN];
^
medians.c:10:16: error: 'true' undeclared (first use in this function)
used[2 * n] = true;
^
medians.c:10:16: note: each undeclared identifier is reported only once for each function it appears in
medians.c:22:21: error: 'false' undeclared (first use in this function)
if(used[b[i]] == false) {
^
medians.c:8:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
medians.c:12:30: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
^