답안 #104116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104116 2019-04-04T05:58:20 Z faustaadp 중앙값 배열 (balkan11_medians) C++17
0 / 100
119 ms 14840 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
ll n,i,a[202020],b[202020],sud[202020],jaw[202020],j;
set<ll> st;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<n;i++)b[a[i]]++;
	for(i=1;i<=n*2-1;i++)
		if(b[i]==0)
			st.insert(i);
	jaw[1]=a[1];
	for(i=n-1;i>=1;i--)
	{
		if(a[i]>a[i+1])
		{
			j=*st.upper_bound(a[i]);
			sud[j]=1;
			jaw[i*2]=j;
			st.erase(j);
			j=*st.upper_bound(a[i]);
			sud[j]=1;
			jaw[i*2+1]=j;
			st.erase(j);
		}
		else
		if(a[i]<a[i+1])
		{
			j=*st.lower_bound(a[i]);
			sud[j]=1;
			jaw[i*2]=j;
			st.erase(j);
			j=*st.lower_bound(a[i]);
			sud[j]=1;
			jaw[i*2+1]=j;
			st.erase(j);
		}
		else
		{
			j=*st.lower_bound(a[i]);
			sud[j]=1;
			jaw[i*2]=j;
			st.erase(j);
			j=*st.upper_bound(a[i]);
			sud[j]=1;
			jaw[i*2+1]=j;
			st.erase(j);
		}	
		b[a[i]]--;
		if(b[a[i]]==0&&sud[a[i]]==0)st.insert(a[i]);
	}
	for(i=1;i<=(n*2-1);i++)
		if(i<(n*2-1))
			cout<<jaw[i]<<" ";
		else
			cout<<jaw[i]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Incorrect 2 ms 384 KB Not a permutation
3 Incorrect 2 ms 384 KB Not a permutation
4 Incorrect 2 ms 384 KB Not a permutation
5 Incorrect 2 ms 384 KB Not a permutation
6 Incorrect 2 ms 384 KB Not a permutation
7 Incorrect 2 ms 384 KB Not a permutation
8 Incorrect 2 ms 384 KB Not a permutation
9 Incorrect 2 ms 384 KB Not a permutation
10 Incorrect 2 ms 384 KB Not a permutation
11 Incorrect 3 ms 412 KB Not a permutation
12 Incorrect 3 ms 512 KB Not a permutation
13 Incorrect 4 ms 512 KB Not a permutation
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 640 KB Not a permutation
2 Incorrect 7 ms 896 KB Not a permutation
3 Incorrect 10 ms 1536 KB Not a permutation
4 Incorrect 16 ms 2688 KB Not a permutation
5 Incorrect 31 ms 4984 KB Not a permutation
6 Incorrect 68 ms 9948 KB Not a permutation
7 Incorrect 119 ms 14840 KB Not a permutation