Codeforces Round #154 (Div. 2)——B

来源:互联网 发布:powermill编程视频教程 编辑:程序博客网 时间:2024/06/02 08:40
B. Physics Practical
time limit per test
1 second
memory limit per test
256 megabytes
input
input.txt
output
output.txt

One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the results in the notebook. After that he was about to show the results to the teacher, but he remembered that at the last lesson, the teacher had made his friend Petya redo the experiment because the largest and the smallest results differed by more than two times. Vasya is lazy, and he does not want to redo the experiment. He wants to do the task and go home play computer games. So he decided to cheat: before Vasya shows the measurements to the teacher, he will erase some of them, so as to make the largest and the smallest results of the remaining measurements differ in no more than two times. In other words, if the remaining measurements have the smallest result x, and the largest result y, then the inequality y ≤ 2·x must fulfill. Of course, to avoid the teacher's suspicion, Vasya wants to remove as few measurement results as possible from his notes.

Help Vasya, find what minimum number of measurement results he will have to erase from his notes so that the largest and the smallest of the remaining results of the measurements differed in no more than two times.

Input

The first line contains integer n (2 ≤ n ≤ 105) — the number of measurements Vasya made. The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 5000) — the results of the measurements. The numbers on the second line are separated by single spaces.

Output

Print a single integer — the minimum number of results Vasya will have to remove.

Sample test(s)
input
64 5 3 8 3 7
output
2
input
44 3 2 4
output
0
Note

In the first sample you can remove the fourth and the sixth measurement results (values 8 and 7). Then the maximum of the remaining values will be 5, and the minimum one will be 3. Or else, you can remove the third and fifth results (both equal 3). After that the largest remaining result will be 8, and the smallest one will be 4.

#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;#define maxn 100005int c[maxn];int main(){    freopen("input.txt", "rt", stdin);    freopen("output.txt", "wt", stdout);    int n,i,j;    scanf("%d",&n);    for(i=0;i<n;i++)        scanf("%d",c+i);    sort(c,c+n);    int ans=0;    for(i=0,j=0;i<n;i++)    {        while(j<n&&c[j]<=2*c[i]) j++;        ans=max(ans,j-i);    }    printf("%d",n-ans);    return 0;}


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 饭卡消磁了怎么办妙招 有好项目没资金怎么办 买的股票涨停了怎么办 考研没过国家线怎么办 中石化的油卡怎么办 5173号被找回了怎么办 谭木匠梳子断了怎么办 198地块上的企业怎么办 天猫投诉不成立怎么办 顾客老嫌瓷砖贵怎么办 公司的公章丢了怎么办 物业不给充电费怎么办 怎么办社保卡去哪里办 单位没给社保卡怎么办 诈骗链接点开了怎么办 私人老板拖欠工资不给怎么办 辞职了工资不发怎么办 老板欠工资不给怎么办 投资平台跑路了怎么办 眼镜太松往下滑怎么办 塑胶水管管断了怎么办 淘宝排名靠后了怎么办 我有古董想出售怎么办 被拍卖公司骗了怎么办 苹果4s铃声太小怎么办 新号码注册微信怎么办 uc不能下种子了怎么办 刚出生的小牛喘怎么办 回奶之后有硬块怎么办 回奶第十天硬块怎么办 断奶期间乳房有硬块怎么办 断奶后乳房有肿块怎么办 北京一证通到期怎么办 没做过后勤的人怎么办 别样app被税了怎么办 人肉代购被税了怎么办 网易考拉被税了怎么办 家住乐清被税了怎么办 糖耐结果高了怎么办 35岁之后死档案怎么办 档案被自己拆了怎么办