一个很简单的题;

方法一:

二分。

代码:

 #include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std; int num[maxn],n; int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
scanf("%d",&n);
for(int i=;i<n;i++)scanf("%d",&num[i]);
sort(num,num+n);
int ans=;
for(int i=;i<n;i++)
{
int x=upper_bound(num,num+n,*num[i])-num-i;
if(ans<x)ans=x;
}
printf("%d\n",n-ans);
return ;
}

方法二:

双端队列;

代码:

 #include<cstdio>
#include<algorithm>
#include<queue>
#define maxn 100005
using namespace std; int num[maxn],n;
queue<int>q; int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
scanf("%d",&n);
for(int i=;i<n;i++)scanf("%d",&num[i]);
sort(num,num+n);
int ans=;
for(int i=;i<n;i++)
{
q.push(num[i]);
if(q.front()*<q.back())q.pop();
if(ans<q.size())ans=q.size();
}
printf("%d\n",n-ans);
return ;
}

Codeforces Round #154 (Div. 2) : B的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

随机推荐

  1. 移动測试技术保护源码!解码全球首款移动端白盒測试工具ThreadingTest (文章转自己主动点科技)

    作者 智晓锋 - 2014/07/14 自从斯诺登曝光美监听丑闻事件之后,我国政府就将信息安全问题上升到了国家安全的高度.基于此.国内的一家创业公司推出了智能型Android真机白盒測试以及开发辅助类 ...

  2. bash登录式shell(完全切换)与非登陆式shell(不完全切换)区别

    1.以登录式shell切换用户 su - username 登录式shell读取配置文件及其顺序: /etc/profile /etc/profile.d/*.sh ~/.bash_profile ~ ...

  3. spring security 11种过滤器介绍

    1.HttpSessionContextIntegrationFilter 位于过滤器顶端,第一个起作用的过滤器. 用途一,在执行其他过滤器之前,率先判断用户的session中是否已经存在一个Secu ...

  4. SSO单点登录之数据同步

    完成单点登录,我们便可以通过只登录一个账号,来访问不同系统,然而会遇到以下问题. 1. 通过A站登录的用户访问B站,在B站并没有真实用户,此时如果在B站新建用户,则可能造成用户信息不全,或者数据冲突等 ...

  5. linux下安装mysql5.6(官方文档)

    Using the MySQL Yum Repository  /  Installing MySQL on Linux Using the MySQL Yum Repository Chapter ...

  6. Lucene 排序 Sort与SortField

    在sql语句中,有升序和降序排列.在Lucene中,同样也有. Sort里的属性 SortField里的属性 含义 Sort.INDEXORDER SortField.FIELD_DOC 按照索引的顺 ...

  7. dp题目

    从别的地方看来,最近一直在啃DP,有个目标,更有动力了. 1.Robberies 连接 :http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包; ...

  8. [lua]再版jobSchedule与脚本描述范型

    首先贴上代码 -- CPM:关键路径法(Critical Path Method) jobSchedule = { todos = { -- todo list ... ["finale&q ...

  9. 各大浏览器内核(Rendering Engine)

    记得刚开始写网页的时候,听童鞋们说各大浏览器的内核,也是懵懵懂懂的,知一不知其二,今天特地查一下: 内核只是一个通俗的说法,其英文名称为“Layout engine”,翻译过来就是“排版引擎”,也被称 ...

  10. 读书笔记之 - javascript 设计模式 - 观察者模式

    在事件驱动的环境中,比如浏览器这种持续寻求用户关注的环境中,观察者模式是一种管理人与其任务(确切的讲,是对象及其行为和状态之间的关系)之间的关系的得力工具.用javascript的话来讲,这种模式的实 ...