답안 #54314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54314 2018-07-03T06:48:44 Z Mahmoud_Adel 중앙값 배열 (balkan11_medians) C++14
0 / 100
6 ms 744 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update


#define f first
#define s second
#define pb push_back
#define mp make_pair
#define clr(dp,i) memset(dp,i,sizeof(dp))
#define opt     ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> oset;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const long long mod = 1e9+7;
const ld pi = 3.14159265358979323846264338327950288;
//========================================
int vis[200001];
int main()
{
	freopen("medians.in", "r", stdin);
	freopen("medians.out", "w", stdout);
	opt;
	int n;
	cin >> n;
	int a[n];
	oset med;
	int bot = 1;
	int top = n*2 - 1;
	for(int i=0; i<n; i++)
	cin >> a[i];
	vector<int> vec;
	for(int i=0; i<n; i++)
	{
		if(!vis[a[i]])
		{
			vec.pb(a[i]);
			vis[a[i]] = 1;
			med.insert(a[i]);
		}
		int x = med.order_of_key(a[i]);
  		x = i - x;
		int sz = i * 2 + 1;
		int y = (sz - med.size()) - x;
		//cout << x << " " << y << endl;
		while(x > 0)
		{
			if(!vis[bot])
			x--, vis[bot] = 1, med.insert(bot), vec.pb(bot);
			bot++;
		}
		while(y > 0)
		{
			if(!vis[top])
			y--, vis[top] = 1, med.insert(top), vec.pb(top);
			top--;
		}
	}
	for(int i : vec)
	cout << i << " ";
	cout << endl;
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:28:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("medians.in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
medians.cpp:29:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("medians.out", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Unexpected end of file - int32 expected
2 Incorrect 4 ms 484 KB Unexpected end of file - int32 expected
3 Incorrect 4 ms 484 KB Unexpected end of file - int32 expected
4 Incorrect 4 ms 484 KB Unexpected end of file - int32 expected
5 Incorrect 4 ms 484 KB Unexpected end of file - int32 expected
6 Incorrect 4 ms 484 KB Unexpected end of file - int32 expected
7 Incorrect 5 ms 492 KB Unexpected end of file - int32 expected
8 Incorrect 4 ms 668 KB Unexpected end of file - int32 expected
9 Incorrect 4 ms 668 KB Unexpected end of file - int32 expected
10 Incorrect 4 ms 668 KB Unexpected end of file - int32 expected
11 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
12 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
13 Incorrect 5 ms 744 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
2 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
3 Incorrect 6 ms 744 KB Unexpected end of file - int32 expected
4 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
5 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
6 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected
7 Incorrect 4 ms 744 KB Unexpected end of file - int32 expected