题意:后一个比前一个大就加一,问最大次数。

 #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的更多相关文章

  1. codeforces 651B Beautiful Paintings

    B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. CodeForces 651B Beautiful Paintings 贪心

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Codeforces 651B Beautiful Paintings【贪心】

    题意: 给定序列,重新排序,使严格上升的子序列最多.求这些子序列总长度. 分析: 贪心,统计每个元素出现次数,每次从剩余的小的开始抽到大的,直到不再剩余元素. 代码: #include<iost ...

  4. codeforces 651B B. Beautiful Paintings

    B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...

  5. Codeforces Round #345 (Div. 2) B. Beautiful Paintings 暴力

    B. Beautiful Paintings 题目连接: http://www.codeforces.com/contest/651/problem/B Description There are n ...

  6. Codeforces 651 B. Beautiful Paintings

    B. Beautiful Paintings   time limit per test 1 second memory limit per test 256 megabytes input stan ...

  7. 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 ...

  8. 【CodeForces 651B】Beautiful Paintings 排序+贪心

    题目大意: 给定集合,对于任意一个的排列,记,求. 很明显每次搞出一个长度为的最长上升序列,然后把元素给删掉,答案增加. 直接暴力需要. 但是可以进行优化. 设有个,将个数从小到大排序,记为长度为的数 ...

  9. Beautiful Paintings CodeForces - 651B (贪心)

    大意: 给定序列$a$, 可以任意排序, 求最大下标i的个数, 满足$a_i<a_{i+1}$. 这个贪心挺好的, 答案就为n-所有数字出现次数最大值.

随机推荐

  1. 整理grep实战文本搜索过滤技巧

    一:grep的简介: 文本搜索工具,根据用户指定的文本模式对目标文件进行逐行搜索,显示能够被模式所匹配到的行.配合正则表达式的使用可以实现强大的文本处理.下面一一说明正则的例子. 二:文本处理工具分类 ...

  2. 学会Twitter Bootstrap不再难

    Twitter Bootstrap 3.0 是对其过去的重大改变,现在它更偏向于移动应用的框架,并且宣称是最好的web设计css框架之一,的确如此. 可能有人曾经使用过Twitter Bootstra ...

  3. 自己写的Python数据库连接类和sql语句拼接方法

    这个工具类十分简单和简洁. sql拼接方法 # encoding=utf-8 from django.http import HttpResponse from anyjson import seri ...

  4. 关于javac编译时出现“非法字符:\65279”的解决方法

    一般用UE或记事本编辑过的UTF-8的文件头会加入BOM标识,该标识由3个char组成.在UTF-8的标准里该BOM标识是可有可无的,Sun 的javac 在编译带有BOM的UTF-8的格式的文件时会 ...

  5. stm32类型cl、vl、xl、ld、md、hd的含义

    - startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for ...

  6. 认识基本的UI资源

    什么是UI精灵(Sprite) 在制作UI时,经常将一些零碎的小的UI资源(比如,一个小箭头,一个按钮等)打包成一张大图,然后在使用时,只使用这个大图中的一部分,那么这一块"被切出来&quo ...

  7. js复制黏贴

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. 一些常用的jQuery插件

    1. X-editable 这个插件能够让你在页面上创建可编辑的元素.它能够使用任何引擎(bootstrap.jquery-ui.jquery),并且包含弹出式和内联模式. 2. Garlic.js ...

  9. hex(x) 将整数x转换为16进制字符串

    >>> a = 122 >>> b = 344 >>> c = hex(a) >>> d = hex(b) >>&g ...

  10. 在Unity中高效工作(上)

    原地址:http://www.unity蛮牛.com/thread-19974-1-1.html 编的话:感谢做编程的IT朋友,帮我翻译文章,我又稍稍做了些修改.给点儿掌声哩.欢迎大家多多评论呦. 我 ...