CodeForces 605A Sorting Railway Cars 思维
早起一水……
题意看着和蓝桥杯B组的大题第二道貌似一个意思……
不过还是有亮瞎双眼的超短代码……
总的意思呢……
就是最长增长子序列且增长差距为1的的……
然后n-最大长度……
这都怎么想的……
希望今天的省选可以亮光乍现~~~
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[];
int b[];
int main(){
int n;
while(~scanf("%d",&n)){
a[]=;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
b[a[i]]=b[a[i]-]+;
}
sort(b+,b+n+);
printf("%d\n",n-b[n]);
}
return ;
}
CodeForces 605A Sorting Railway Cars 思维的更多相关文章
- CodeForces 605A Sorting Railway Cars
求一下最长数字连续上升的子序列长度,n-长度就是答案 O(n)可以出解,dp[i]=dp[i-1]+1,然后找到dp数组最大的值. #include<cstdio> #include< ...
- Codeforces 335C Sorting Railway Cars
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- [Codeforces 606C]Sorting Railway Cars
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- CodeForces 606C Sorting Railway Cars(最长连续上升子序列)
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- cf 605A Sorting Railway Cars 贪心 简单题
其实就是求总长度 - 一个最长“连续”自序列的长度 最长“连续”自序列即一个最长的lis,并且这个lis的值刚好是连续的,比如4,5,6... 遍历一遍,贪心就是了 遍历到第i个时,此时值为a[i], ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 动态规划
C. Sorting Railway Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/conte ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 连续LIS
C. Sorting Railway Cars An infinitely long railway has a train consisting of n cars, numbered from ...
- Codeforces 606-C:Sorting Railway Cars(LIS)
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #335 (Div. 2) C. Sorting Railway Cars
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- MATLAB初体验
好激动 要入MATLAB的大坑了 恩 很遗憾第一个程序并不是hello world 好 插入代码里并没有MATLAB这个选项 这是一种歧视 x=[:pi/:*pi]; y=sin(x); plot(x ...
- Linux 分区挂载方案
/boot 1G swap 2G(看内存决定) / 10-15G /home 5G
- 切换self.window.rootViewController根视图,导致上一视图控制器不能释放销毁的问题
在我们APP开发中经常有首次进入应用先进入引导页或者登陆页的情况,类似下图所示 发现登陆以后更改window.rootViewController为应用首页时,登陆页没有销毁掉,通过图层工具 ...
- CodeForces 659F Polycarp and Hay
并查集,$dfs$. 从大的数字往里加,每加一个数字合并一下连通块,判断连通块内数字个数是否够,以及k能不能被当前加入的数字整除.然后$dfs$一下构造答案. #pragma comment(link ...
- StringMVC(拦截器)
单个拦截器 使用jar包 创建FirstController.java @Controller public class FirstController { @RequestMapping(" ...
- 2-Bom
前言 window对象是BOM的顶层(核心)对象,所有对象都是通过它延伸出来的,也可以称为window的子对象.由于window是顶层对象,因此调用它的子对象时可以不显示的指明window对象 例如下 ...
- 前端tab页实例
<div class="tabbable"> <ul class="nav nav-tabs padding-16"> <c:fo ...
- linux配置更改yum源
1,进入yum源配置目录 cd /etc/yum.repos.d 2,备份系统自带的yum源mv CentOS-Base.repo CentOS-Base.repo.bk下载163网易的yum源:wg ...
- H5移动端页面设计心得分享(转载)
去年JDC出了不少优秀的武媚娘…不,H5呢,大家都很拼,同时当然也积累了一些经验和教训,今天结合咱们的实战案例,从字体,排版,动效,音效,适配性,想法这几个方面好好聊一聊关于H5的设计,希望对同学们有 ...
- 基于PHP——简单的WSDL的创建(WSDL篇)
1.建立WSDL文件 建立WSDL的工具很多,eclipse.zendstudio.vs都可以,我个人建议自己写,熟悉结构,另外自动工具对xml schame类型支持在类型中可能会报错. 下 ...