Codeforces Round #154 (Div. 2) : B
一个很简单的题;
方法一:
二分。
代码:
#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的更多相关文章
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Hadoop-2.4.1学习之Map任务源代码分析(下)
在Map任务源码分析(上)中,对MAP阶段的代码进行了学习,这篇文章文章将学习Map任务的SORT阶段.假设Reducer的数量不为0.则还须要进行SORT阶段.但从上面的学习中并未发现与MAP阶段运 ...
- WTL 自绘 进度条Progressbar
WTL 绘制的进度条,逻辑清晰明了,代码函数清晰易懂:基本思路就是 首先绘制 进度条背景图,然后根据动态进度不断重绘前景进度条,绘制操作在OnPaint函数里画.该类可以直接用于项目中. 使用示例: ...
- RedHat7搭建PHP开发环境(Zend Studio)
下载Zend Studio # wget http://downloads.zend.com/studio-eclipse/13.0.1/ZendStudio-13.0.1-linux.gtk.x86 ...
- replace()、replaceFirst()和replaceAll()的区别
1.replace() String str= "mesquite in your cellar" str.replace('e', 'o') returns "mosq ...
- 当append里面的标签显示不出来的时候,用下面的方式做
$("#result_td").append(tem1+tem3) $("#result_td").append($(tem1+tem3))
- [上传下载] C#FileUp文件上传类 (转载)
点击下载 FileUp.zip 主要功能如下 .把上传的文件转换为字节数组 .流转化为字节数组 .上传文件根据FileUpload控件上传 .把Byte流上传到指定目录并保存为文件 看下面代码吧 // ...
- [分词] C#SegList分词辅助类,帮助类 (转载)
点击下载 SegList.rar 主要功能如下最新的SegList分词辅助类,帮助类看下面代码吧 /// <summary> /// 类说明:SegList /// 编 码 人:苏飞 // ...
- BUG Error:Execution failed for task ':app:dexDebug'.
Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessExceptio ...
- C#删除数组元素代码
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- C# 控制台窗口的显示与隐藏
1. 定义一个Consolse帮助类,如下: /// <summary> /// 控制台帮助类 /// </summary> public static class Conso ...