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 ...
随机推荐
- 为Dapper编写一个类似于EF的Map配置类
引言 最近在用Dapper处理Sqlite.映射模型的时候不喜欢用Attribute配置,希望用类似EF的Map来配置,所以粗略的实现了一个. 实现 首先是主体的配置辅助类型: using Syste ...
- Akka Stream文档翻译:Motivation
动机 Motivation The way we consume services from the internet today includes many instances of streami ...
- 中国首个 SaaS 模式的云告警平台安卓版 APP 上线
今年一月底,国内首个 SaaS 模式的云告警平台 OneAlert 正式发布了 iOS 版 App 客户端,今天上午,安卓版 App 客户端也正式上线了!每个安卓用户,无需电脑,都可以通过手机全程跟踪 ...
- android 官方教程中文版
感谢这些默默奉献的人 :) https://github.com/kesenhoo/android-training-course-in-chinese http://hukai.me/android ...
- SQLite数据类型详解
一.存储种类和数据类型: SQLite将数据值的存储划分为以下几种存储类型: 复制代码代码如下: NULL: 表示该值为NULL值. INTEGER: 无符号整型值. R ...
- Fundamental Datastructure
11988 - Broken Keyboard (a.k.a. Beiju Text) 可以用deque来模拟. #include <iostream> #include <stri ...
- 一篇文章教会你,如何做到招聘要求中的“要有扎实的Java基础
来历 本文来自于一次和群里猿友的交流,具体的情况且听LZ慢慢道来. 一日,LZ在群里发话,“招人啦.” 然某群友曰,“群主,俺想去.” LZ回之,“你年几何?” 群友曰,“两年也.” LZ憾言之,“惜 ...
- cache设计,以及多核造成的不一致性以及解决方案
http://www.360doc.com/content/11/1013/00/1317564_155625188.shtml http://blog.csdn.net/muxiqingyang/a ...
- mysql 闪回表工具
use HTTP::Date qw(time2iso str2time time2iso time2isoz); use POSIX; my $SDATE = strftime("%Y-%m ...
- 【HDOJ】4322 Candy
状态DP显然可以解,发现T了,不知道优化后能不能过.然后发现费用流可以解.trick是对need拆解成need/K, need%K两种情况讨论. /* 4312 */ #include <ios ...