题目链接:http://codeforces.com/problemset/problem/372/A
二分思想
AC代码:
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[500005];
int main() {
int n;
while(scanf("%d",&n) != EOF) {
for(int i = 0;i < n;i++) {
scanf("%d",&arr[i]);
}
sort(arr,arr+n);
int l = 0,r = n/2,ans = 0;
while(l < n/2) {
while(r < n && arr[r] < 2 * arr[l]) {
r++;
}
if(arr[r] >= 2 * arr[l]) {
r++;
ans++;
}
l++;
}
printf("%d\n",n-ans);
}
return 0;
}