답안 #160624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160624 2019-10-29T01:06:37 Z luciocf 중앙값 배열 (balkan11_medians) C++14
0 / 100
32 ms 2424 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5+10;

int a[maxn];

bool mark[maxn];

int main(void)
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	int l = 1, r = 2*n-1;

	printf("%d", a[1]);
	mark[a[1]] = 1;

	for (int i = 2; i <= n; i++)
	{
		if (a[i] == a[i-1])
		{
			while (mark[l]) l++;
			while (mark[r]) r--;

			printf(" %d %d", l, r);
		}
		else if (a[i] < a[i-1])
		{
			if (mark[a[i]])
			{
				while (mark[l]) l++;
				printf(" %d", l);
				while (mark[l]) l++;
				printf(" %d", l);
			}
			else
			{
				printf(" %d", a[i]);
				while (mark[l]) l++;
				printf(" %d", l);
			}
		}
		else
		{
			if (mark[a[i]])
			{
				while (mark[r]) r--;
				printf(" %d", r);
				while (mark[r]) r--;
				printf(" %d", r);
			}
			else
			{
				printf(" %d", a[i]);
				while (mark[r]) r--;
				printf(" %d", r);
			}
		}
	}

	printf("\n");
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
medians.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Not a permutation
2 Incorrect 2 ms 256 KB Not a permutation
3 Incorrect 2 ms 376 KB Not a permutation
4 Incorrect 4 ms 376 KB Not a permutation
5 Incorrect 2 ms 376 KB Not a permutation
6 Incorrect 2 ms 376 KB Not a permutation
7 Incorrect 2 ms 376 KB Not a permutation
8 Incorrect 2 ms 376 KB Not a permutation
9 Incorrect 2 ms 376 KB Not a permutation
10 Incorrect 2 ms 376 KB Not a permutation
11 Incorrect 2 ms 376 KB Not a permutation
12 Incorrect 2 ms 376 KB Not a permutation
13 Incorrect 2 ms 376 KB Not a permutation
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 380 KB Not a permutation
2 Incorrect 3 ms 376 KB Not a permutation
3 Incorrect 5 ms 504 KB Not a permutation
4 Incorrect 7 ms 632 KB Not a permutation
5 Incorrect 11 ms 888 KB Not a permutation
6 Incorrect 23 ms 1656 KB Not a permutation
7 Incorrect 32 ms 2424 KB Not a permutation