# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25888 | bugmenot111 | medians (balkan11_medians) | C11 | 23 ms | 2092 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdbool.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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |