Submission #25888

# Submission time Handle Problem Language Result Execution time Memory
25888 2017-06-25T00:09:48 Z bugmenot111 medians (balkan11_medians) C
0 / 100
23 ms 2092 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 2092 KB Not a permutation
3 Incorrect 0 ms 2092 KB Not a permutation
4 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
5 Incorrect 0 ms 2092 KB Not a permutation
6 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
7 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
8 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
9 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
10 Incorrect 0 ms 2092 KB Not a permutation
11 Incorrect 0 ms 2092 KB Not a permutation
12 Incorrect 0 ms 2092 KB Not a permutation
13 Incorrect 0 ms 2092 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2092 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 2092 KB Not a permutation
3 Incorrect 0 ms 2092 KB Not a permutation
4 Incorrect 3 ms 2092 KB Unexpected end of file - int32 expected
5 Incorrect 9 ms 2092 KB Not a permutation
6 Incorrect 19 ms 2092 KB Not a permutation
7 Incorrect 23 ms 2092 KB Not a permutation