-
Notifications
You must be signed in to change notification settings - Fork 5
/
372A.cpp
65 lines (48 loc) · 780 Bytes
/
372A.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <algorithm>
using namespace std;
int arr[5*(int)1e5 + 5];
bool bs( int m, int i ) {
if ( 2*arr[m] <= arr[i] ) return true;
return false;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &arr[i]);
}
sort(arr,arr+n);
int ans = n;
int start = 0;
int end = n/2 - ( n % 2 == 0 ? 1 : 0 );
int end2 = end;
int k = -1;
int mid;
for (int i = n-1; i > end2; --i)
{
while( start <= end ) {
mid = ( start + end ) / 2;
if ( bs( mid , i ) )
{
start = mid + 1;
k = mid;
}
else
{
end = mid - 1;
}
}
if ( k == -1 ) {
break;
}
else {
end = k - 1;
k = -1;
start = 0;
ans--;
}
}
printf("%d\n", ans);
}