codeforce 651B Beautiful Paintings
题意:后一个比前一个大就加一,问最大次数。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=1e5+;
const double eps=1e-;
const double pi=acos(-);
const int inf = 0x3f3f3f3f;
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a)) int main()
{
int n;
scanf("%d",&n);
int a[];
clc(a,);
for(int i=;i<n;i++)
{
int x;
scanf("%d",&x);
a[x]++;
}
int maxx=-inf;
for(int i=;i<=;i++)
{
if(maxx<a[i])
maxx=a[i];
}
printf("%d\n",n-maxx);
return ;
}
codeforce 651B Beautiful Paintings的更多相关文章
- codeforces 651B Beautiful Paintings
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CodeForces 651B Beautiful Paintings 贪心
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces 651B Beautiful Paintings【贪心】
题意: 给定序列,重新排序,使严格上升的子序列最多.求这些子序列总长度. 分析: 贪心,统计每个元素出现次数,每次从剩余的小的开始抽到大的,直到不再剩余元素. 代码: #include<iost ...
- codeforces 651B B. Beautiful Paintings
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #345 (Div. 2) B. Beautiful Paintings 暴力
B. Beautiful Paintings 题目连接: http://www.codeforces.com/contest/651/problem/B Description There are n ...
- Codeforces 651 B. Beautiful Paintings
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #345 (Div. 2)——B. Beautiful Paintings(贪心求上升序列个数)
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 【CodeForces 651B】Beautiful Paintings 排序+贪心
题目大意: 给定集合,对于任意一个的排列,记,求. 很明显每次搞出一个长度为的最长上升序列,然后把元素给删掉,答案增加. 直接暴力需要. 但是可以进行优化. 设有个,将个数从小到大排序,记为长度为的数 ...
- Beautiful Paintings CodeForces - 651B (贪心)
大意: 给定序列$a$, 可以任意排序, 求最大下标i的个数, 满足$a_i<a_{i+1}$. 这个贪心挺好的, 答案就为n-所有数字出现次数最大值.
随机推荐
- MVC之重定向
MVC的重定向主要通过RedirectResult和RedirectToRouteResult实现.很显然,这两个对象都是MVC返回对象ActionResult的两个继承,具体原理不赘述. 这两个方法 ...
- 从Windows远程Ubuntu
关键字:Windows,Ubuntu,Putty,WinSCP OS:Windows 7,Ubuntu. 1.下载Putty:http://www.putty.org/. 2.双击运行putty.ex ...
- 泛型转Datatable
//自定义扩展方法 public static class ExtMethod { //泛型转为DataTable public static DataTable AsDataTable<T&g ...
- hdu 5646 DZY Loves Partition 二分+数学分析+递推
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5646 题意:将n分成k个正整数之和,要求k个数全部相同:并且这k个数的乘积最大为多少?结果mod 1e^9 ...
- 7.MVC框架开发(创建层级项目)
在一个项目比较大的时候,就会有多个层级项目 1)在项目中选定项目右建新建区域(新的层级项目),项目->右键->添加->区域,构成了一套独立的MVC的目录,这个目录包括Views,Co ...
- BZOJ 1227 虔诚的墓主人
Description 小W 是一片新造公墓的管理人.公墓可以看成一块N×M 的矩形,矩形的每个格点,要么种着一棵常青树,要么是一块还没有归属的墓地.当地的居民都是非常虔诚的基督徒,他们愿意提前为自己 ...
- jquery方法的参数解读
18:22 2013/9/21 attr(name|properties|key,value|fn) 概述 设置或返回被选元素的属性值. 在jquery中[]表示可选参数,你可以不选,| 表示参数可以 ...
- 事件分发&响应链
iOS的三种事件:触摸事件/运动事件/远程控制事件 typedef enum { UIEventTypeTouches, UIEventTypeMotion, UIEventTypeRemoteCon ...
- Memcached(四)Memcached的CAS协议
1. 什么是CAS协议很多中文的资料都不会告诉大家CAS的全称是什么,不过一定不要把CAS当作中国科学院(China Academy of Sciences)的缩写.Google.com一下,CAS是 ...
- http://blog.csdn.net/shirdrn/article/details/6270506
http://blog.csdn.net/shirdrn/article/details/6270506