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

思路:最长连续子序列。

 #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. HDU1180+BFS

    bfs思路:三维标记状态 && 处理好 - | 和时刻的关系即可 /* bfs 思路:三维标记状态 && 处理好 - | 和时刻的关系即可 */ #include< ...

  2. marmalade android 5.0 JNI 调用失败的解决方案

    5.0 真机日志如下:sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV call ...

  3. HeadFirst设计模式之命令模式

    一. 1.因为是操作经常变化,所以封装操作为command对象.You can do that by introducing “command objects” into your design. A ...

  4. Delphi里的RTTI与反射(举例换掉FOnChange)

    Delphi2010之后的RTTI做了很大休整,现在用起来很爽了哦.甚至可以获取某些类的内部私有单元,然后为其赋值!讲这个RTTI增强的,可以参考网上的多个博客内容,我列举一下:Delphi2010R ...

  5. Hbase二级索引

    http://blog.sina.com.cn/s/blog_4a1f59bf01018apd.html

  6. CentOS 命令随笔

     linux下敲命令时:快速删除当前行已经敲的命令: CTR+U  或者 CTR+/                         快速删除当前行刚输入接近鼠标当前位置的单词:CTR+W 以上在XS ...

  7. 【HDOJ】3686 Traffic Real Time Query System

    这题做了几个小时,基本思路肯定是求两点路径中的割点数目,思路是tarjan缩点,然后以割点和连通块作为新节点见图.转化为lca求解.结合点——双连通分量与LCA. /* 3686 */ #includ ...

  8. Oracle EBS Report 输出字符字段前部"0"被Excel自动去掉问题

    Oracle  EBS 提供多种报表的开发和输出形式,由于MS Excel在处理数据方面的优势明显,报表输出用Excel打开是很常见的开发项. 但是正是由于Excel的"过于智能而不智能&q ...

  9. Hadoop伪分布模式配置部署

    .实验环境说明 注意:本实验需要按照上一节单机模式部署后继续进行操作 1. 环境登录 无需密码自动登录,系统用户名 shiyanlou,密码 shiyanlou 2. 环境介绍 本实验环境采用带桌面的 ...

  10. 第三部分 overlay 学习

    前文仅了解了overlay HAL的架构,下面继续看看系统层是如何调用Overlay模块. 1.测试代码 frameworks/base/libs/surfaceflinger/tests/overl ...