codeforce 606C - Sorting Railway Cars
题意:给你一串数,没个数只能往前提到首位,或则往后放末尾。问最少步骤使操作后的序列成上升序列。
思路:最长连续子序列。
#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的更多相关文章
- [Codeforces 606C]Sorting Railway Cars
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- CodeForces 606C Sorting Railway Cars(最长连续上升子序列)
Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...
- 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 ...
- CF#335 Sorting Railway Cars
Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- 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 ...
- 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 ...
- A. Sorting Railway Cars
A. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 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 ...
- Codeforces 335C Sorting Railway Cars
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
随机推荐
- HDU1180+BFS
bfs思路:三维标记状态 && 处理好 - | 和时刻的关系即可 /* bfs 思路:三维标记状态 && 处理好 - | 和时刻的关系即可 */ #include< ...
- marmalade android 5.0 JNI 调用失败的解决方案
5.0 真机日志如下:sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV call ...
- HeadFirst设计模式之命令模式
一. 1.因为是操作经常变化,所以封装操作为command对象.You can do that by introducing “command objects” into your design. A ...
- Delphi里的RTTI与反射(举例换掉FOnChange)
Delphi2010之后的RTTI做了很大休整,现在用起来很爽了哦.甚至可以获取某些类的内部私有单元,然后为其赋值!讲这个RTTI增强的,可以参考网上的多个博客内容,我列举一下:Delphi2010R ...
- Hbase二级索引
http://blog.sina.com.cn/s/blog_4a1f59bf01018apd.html
- CentOS 命令随笔
linux下敲命令时:快速删除当前行已经敲的命令: CTR+U 或者 CTR+/ 快速删除当前行刚输入接近鼠标当前位置的单词:CTR+W 以上在XS ...
- 【HDOJ】3686 Traffic Real Time Query System
这题做了几个小时,基本思路肯定是求两点路径中的割点数目,思路是tarjan缩点,然后以割点和连通块作为新节点见图.转化为lca求解.结合点——双连通分量与LCA. /* 3686 */ #includ ...
- Oracle EBS Report 输出字符字段前部"0"被Excel自动去掉问题
Oracle EBS 提供多种报表的开发和输出形式,由于MS Excel在处理数据方面的优势明显,报表输出用Excel打开是很常见的开发项. 但是正是由于Excel的"过于智能而不智能&q ...
- Hadoop伪分布模式配置部署
.实验环境说明 注意:本实验需要按照上一节单机模式部署后继续进行操作 1. 环境登录 无需密码自动登录,系统用户名 shiyanlou,密码 shiyanlou 2. 环境介绍 本实验环境采用带桌面的 ...
- 第三部分 overlay 学习
前文仅了解了overlay HAL的架构,下面继续看看系统层是如何调用Overlay模块. 1.测试代码 frameworks/base/libs/surfaceflinger/tests/overl ...