早起一水……

题意看着和蓝桥杯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 思维的更多相关文章

  1. CodeForces 605A Sorting Railway Cars

    求一下最长数字连续上升的子序列长度,n-长度就是答案 O(n)可以出解,dp[i]=dp[i-1]+1,然后找到dp数组最大的值. #include<cstdio> #include< ...

  2. Codeforces 335C Sorting Railway Cars

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. [Codeforces 606C]Sorting Railway Cars

    Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...

  4. CodeForces 606C Sorting Railway Cars(最长连续上升子序列)

    Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...

  5. cf 605A Sorting Railway Cars 贪心 简单题

    其实就是求总长度 - 一个最长“连续”自序列的长度 最长“连续”自序列即一个最长的lis,并且这个lis的值刚好是连续的,比如4,5,6... 遍历一遍,贪心就是了 遍历到第i个时,此时值为a[i], ...

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

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

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

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

随机推荐

  1. Python网络编程学习_Day9

    一.socketserver实现多并发 socket只能实现单进程通讯,要实现多进程同时和服务端通讯就要使用socketserver. 代码如下: import socket client = soc ...

  2. C++四种cast操作符

    C 风格(C-style)强制转型如下: (T) expression  或 T(expression) //函数风格(Function-style) 两种形式之间没有本质上的不同. 对于具有转换的简 ...

  3. hadoop(一)

    1 环境熟悉安装jdk.hadoop配置xml文件,启动伪分布式运行example-jar,测试mapreduce程序2 mapreduce编程使用eclipse开发mapreduce程序,导出jar ...

  4. Java 后台sql注入

    JdbcTemplate.update(sql, ArrayList.toArray()) Connection conn = null; PreparedStatement ps = null; c ...

  5. CentOS6.5部署L2TP over IPSec

    一.环境介绍: 1.CentOS 6.5 (要求双网卡做软路由,如果只是做VPN可以单网卡) a.外网IP: b.内网IP: 2.Window 10 主机一台做为一台内网测试软路由使用: a.内网IP ...

  6. 关于Objective-C Associated Objects

    一.相关函数 与Associated Objects相关的函数有三个 1 void objc_setAssociatedObject(id object, const void *key, id va ...

  7. Foxit Reader(福昕PDF阅读器) v4.3.1.218 绿色专业版

    软件名称:Foxit Reader(福昕PDF阅读器) v4.3.1.218 绿色专业版 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 4.40MB 图片 ...

  8. 提示找不到xml配置文件

    ClassPathXmlApplicationContext("applicationContext.xml")默认文件夹是resouerces,所以要把xml文件放在这个下面.

  9. Beego学习笔记——Logs

    日志处理 这是一个用来处理日志的库,它的设计思路来自于database/sql,目前支持的引擎有file.console.net.smtp,可以通过如下方式进行安装: go get github.co ...

  10. LoadRunner错误处理函数

    节选自<LoadRunner虚拟用户开发指南> 在脚本的Run-time Settings中,可以设置在脚本运行过程中发生错误的处理方式.进入到Run-time Settings中,切换到 ...