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
|
#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> nums;
vector<int> :: iterator it;
for (int i = 0; i < n; i++) {
int input;
cin >> input;
it = lower_bound(nums.begin(), nums.end(), input);
if ((i+1) % 2) {
//홀수개일때
cout << nums[nums.size()/2] << '\n';
}
else {
//짝수개일 때 -> 중간값 두 개 중 작은 값을 출력
int mid1 = nums[nums.size()/2-1];
int mid2 = nums[nums.size()/2];
int res = mid1 > mid2 ? mid2 : mid1;
cout <<res << '\n';
}
}
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
BOJ/C++