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

思路:最长连续子序列。

 #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. smarty 时间格式化date_format

    代码如下:$smarty = new Smarty; $smarty->assign('yesterday', strtotime('-1 day')); $smarty->display ...

  2. uva 10986

    ford 超时  使用优先队列的Dijkstra 算法 //#include <cstdio> //#include <cstring> //#include <algo ...

  3. tornado做简单socket服务器(TCP)

    http://blog.csdn.net/chenggong2dm/article/details/9041181 服务器端代码如下: #! /usr/bin/env python #coding=u ...

  4. HDU 5039 Hilarity

    题意:一棵树n个结点,每条边有0.1两种权值,每次询问权值为奇数的路径数目,或者改变某一条边的权值. 分析:这个题目很巧妙低利用了异或和的特性,dfs得到每个点到根结点的权值异或和,然后奇数则为1,偶 ...

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

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

  6. 【调侃】IOC前世今生 工厂模式 反射 依赖倒置

    http://www.cnblogs.com/showjan/p/3950989.html

  7. vmware tools安装程序无法继续,Microsoft Runtime DLL安装程序未能完成安装。的解决方法

    vmware tools安装程序无法继续,Microsoft Runtime DLL安装程序未能完成安装.的解决方法_华英雄_新浪博客 http://blog.sina.com.cn/s/blog_5 ...

  8. 智传播客hadoop视频学习笔记(共2天)

    第一天:1.答疑解惑•  就业前景•  学习hadoop要有什么基础•  hadoop会像塞班一样,热一阵子吗•  hadoop学习起来容易还是困难•  课堂上的学习方法(所有实验必须按照要求做,重原 ...

  9. RabbitMQ消息队列(一): Detailed Introduction 详细介绍(转)

    1. 历史 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需求,虽然在同步消息通讯的世界里有 ...

  10. STM32硬件复位时间

    两个参数,,1低电平时间 2低电平压值 1.stm32复位时间 ------  低电平时间:1.5 至 4.5 ms   2.压值