早起一水……

题意看着和蓝桥杯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. 如何解决sql server定时作业调用Kettle job出错

    错误信息: Unable to list jar files in plugin folder 'C:\Windows\system32\config\systemprofile\.kettle\pl ...

  2. Scala减少代码重复

    高阶函数可以把其它函数当作函数参数,帮助我们减少代码重复,例如: object FileMatcher { private def fileHere = (new File(".\\file ...

  3. 回文质数 Prime Palindromes

    题目描述 因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数. 写一个程序来找出范围[a,b](5 <= a < b <= 100,000 ...

  4. Angular2 + NativeScript 跨平台开发笔记(一)

    NativeScript 是一款跟 ReactNative 对着怼的移动开发技术,其官方钦定了 Angular2 作为推荐的技术框架,那么如何让在浏览器中运行的 Angular2 Web app 项目 ...

  5. 《C++反汇编与逆向分析技术揭秘》——流程控制语句的识别

    if...else...语句 示例: if构成多分支语句 switch 有序线性的switch: 3E82D8位置存放了一个表,标明了要跳转到的地址: 这里的每四字节都标明的是每个case块的首地址: ...

  6. 《css揭秘》

    <css揭秘> 第一章:引言 引言 案例们 第二章:背景与边框 背景和边框 半透明边框(rgba/hsla.background-clip) 多重边框(box-shadow) 灵活的背景定 ...

  7. JavaScript忍者秘籍——运行时代码求值

    1. 代码求值机制 JavaScript中,有很多不同的代码求值机制. ● eval()函数 ● 函数构造器 ● 定时器 ● <script>元素 - 用eval()方法进行求值 作为定义 ...

  8. MySql 使用教程(摘自网络)

    一.连接 mysql    格式:mysql-h 主机地址 -u 用户名 p 用户密码    1 例 1 连接到本机上的 mysql    首先在打开 DOS 窗口,然后进入目录 mysql\bin ...

  9. android设备中USB转串口demo 下载

    http://files.cnblogs.com/guobaPlayer/testUSB2Serial.apk USB转串口demo程序, 无需驱动,只要手机USB是OTG类型,插上我们的模块即可使用 ...

  10. 【linux-shell】rsync

    https://en.wikipedia.org/wiki/Rsync https://en.wikipedia.org/wiki/Andrew_Tridgell 安德鲁.锤子,发布了rsync的第一 ...