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-所有数字出现次数最大值.
随机推荐
- Linux下18b20温度传感器驱动代码及测试实例
驱动代码: #include <linux/module.h> #include <linux/fs.h> #include <linux/kernel.h> #i ...
- 不相交集合ADT
不相交集合数据结构保持一组不相交的动态集合S={S1,S2,...,SK},每个集合通过一个代表来识别,代表即集合中的某个成员. 如果x表示一个对象,不相交集合支持以下操作: MAKE-SET(x): ...
- GPU CUDA常量内存使用
#include <cuda.h> #include <stdio.h> int getMulprocessorCount(){ cudaDeviceProp prop; cu ...
- spring IOC源码分析(2)
refresh这个方法包含了整个BeanFactory初始化的过程,定位资源由obtainFreshBeanFactory()来完成, protected ConfigurableListableBe ...
- 数列 COGS1048:[Citric S2] 一道防AK好题
[题目描述] Czy手上有一个长度为n的数列,第i个数为xi. 他现在想知道,对于给定的a,b,c,他要找到一个i,使得a*(i+1)*xi2+(b+1)*i*xi+(c+i)=0成立. 如果有多个i ...
- Temporary Post Used For Theme Detection (da655c32-bc15-41ad-bf89-e76c1ec1bea7 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)
This is a temporary post that was not deleted. Please delete this manually. (997facfe-d420-4437-a222 ...
- loadrunner throughput(吞吐量)理解
转自http://www.51testing.com/html/29/n-110129.html Throughput翻译为吞吐量,按照常规理解网络吞吐量表示在单位时间内通过网卡数据量之和,其中即 ...
- 网络编程(二)NSURLSessionConfiguration
1.NSURLSession有三种工作模式 (1)defaultSessionConfiguration(默认):使用的是基于磁盘缓存的持久化策略,Cache,Cookie. (2)ephemeral ...
- http://blog.csdn.net/carolzhang8406/article/details/7196011
http://blog.csdn.net/carolzhang8406/article/details/7196011
- windows phone 中的TextBlock的一些特性(TextWrapping,TextWrapping)
文字很长时,换行:TextWrapping="Wrap" 文字很长时,省略:TextWrapping="WordEllipsis"