题意:给你一串数,没个数只能往前提到首位,或则往后放末尾。问最少步骤使操作后的序列成上升序列。

思路:最长连续子序列。

 #include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<string.h>
#include<algorithm>
#include<cmath>
const int N = ;
const int inf=-;
using namespace std; int main()
{
int n;
int h[];
int dp[];
int a[];
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
}
int ans=;
for(int i=; i<=n; i++)
{
h[a[i]]++;
if(h[a[i]-])
dp[a[i]]=dp[a[i]-]+;
else
dp[a[i]]=;
ans=max(dp[a[i]],ans);
}
cout<<n-ans<<endl;
return ;
}

codeforce 606C - Sorting Railway Cars的更多相关文章

  1. [Codeforces 606C]Sorting Railway Cars

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

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

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

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

  4. CF#335 Sorting Railway Cars

    Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

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

  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. A. Sorting Railway Cars

    A. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

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

  9. Codeforces 335C Sorting Railway Cars

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

随机推荐

  1. vncserver 添加用户

    1.在vncserver设置登录用户的信息   #vi /etc/sysconfig/vncservers   VNCSERVERS="1:root 2:wt" 此处添加用户   ...

  2. LocalStorage 本地存储

    首先自然是检测浏览器是否支持本地存储.在HTML5中,本地存储是一个window的属性,包括localStorage和sessionStorage,从名字应该可以很清楚的辨认二者的区别,前者是一直存在 ...

  3. ANN中Precision-Recall权衡

    如果想要得到较高的精度,则需要较长的编码. 编码长度m增长的话,则item碰撞的概率会成倍的减小,从而导致召回率下降. 为了得到较高的召回率,则需要多个哈希表. 参考http://yongyuan.n ...

  4. Python中pass语句的作用

    http://mianshi.fenzhi.com/post/1529.html pass语句什么也不做,一般作为占位符或者创建占位程序,pass语句不会执行任何操作,比如:while False:p ...

  5. linux samba.tar.gz安装和配置

    安装步骤: 1. tar -xzvf samba-3.5.10.tar.gz2. cd samba-3.5.103. cd source34. ./autogen.sh  如果出现:./autogen ...

  6. C#一个简单下载程序实例(可用于更新)

    运行时的界面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...

  7. c++ 基础学习: 左值 概念cocos2d-x3.0的实际应用

    左值:概念baidu 1.2.6.2 与Cocos2d-x内存管理的结合 在2.x的使用场景中,CCArray和CCDictionary通常被分配在堆上,我们不得不需要考虑在适当的地方释放其内存.新的 ...

  8. 【转】VC++消息钩子编程

    VC++消息钩子编程

  9. 关于Apache Struts 2 S2-032高危漏洞的一些确认

    2016年4月21日Struts2官方发布两个CVE,其中CVE-2016-3081(S2-032)官方评级为高. 主要原因为在用户开启动态方法调用的情况下,会被攻击者实现远程代码执行攻击. 具体的漏 ...

  10. Oracle 列顺序测试

    列顺序测试 大家在做表设计的时候通常对表中列的排列顺序没有过多注意,但是其实越常用的列,它的位置越靠前,则查询速度越快. 因为每个block里面存储了row directory (每行数据在块中的位移 ...