-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1655.cpp
More file actions
41 lines (39 loc) · 739 Bytes
/
1655.cpp
File metadata and controls
41 lines (39 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <deque>
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int a[20001] = { 0, };
int n, tmp;
cin >> n;
for (int k = 1; k <= n; k++) {
cin >> tmp;
a[tmp+10000]++;
int many = 0; //many:현재 search 중인 위치, m_idx: 중앙값 index
int m_idx =0;
if (k % 2 ==1) {
m_idx = (k+ 1) / 2;
}
else {
m_idx = k / 2;
}
for (int i = 0; i < 20001; i++) {
many += a[i];
if (many >= m_idx) {
printf("%d\n", i-10000);
break;
}
}
}
return 0;
}