Submission #25888

#TimeUsernameProblemLanguageResultExecution timeMemory
25888bugmenot111medians (balkan11_medians)C11
0 / 100
23 ms2092 KiB
#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)

medians.c: In function 'main':
medians.c:9:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ^
medians.c:13: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]);
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...