题目链接:(这个是内网的网址)  http://172.22.27.1/problem?pid=1013

                Good Sequence

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)

Problem Description

A sequence contains n integers.

A sequence p1, p2, p3...pn is a good sequence if it satisfies pi ≤ pi+1. i∈[1, n)<n)<n)<n)< p="">

KIDx likes good sequence very much. So he has made a random generator in order to generate lots of good sequences.

But unfortunately, there is something wrong with his generator so that it always generates bad sequences.

Now, KIDx has to transform every bad sequence to a good one. He can change any integer  in the sequence.

Your task is to find out the minimum number of integers KIDx has to change to get a good sequence.

Input

Each case contains a positive integer n (n ≤ 5000) in the first line and a sequence which contains n integers pi (0 ≤ p< 108) in the second line.

Output

For each test case, output the answer in a single line.

Sample Input

3
60 54 30
5
44 55 100 72 89

Sample Output

2
1 写下这题是为了纪念我蹩脚的DP!!!
求出最长非递减序列的个数,然后拿n - 个数 就是答案
 #include <iostream>
#include <cstdio>
using namespace std; const int maxn = + ;
int p[maxn], dp[*maxn]; int main()
{
int i, j, n;
while (scanf("%d", &n) != EOF)
{
for (i = ; i <= n; i++)
{
scanf("%d", &p[i]);
dp[i] = ;
}
int ans = dp[];
for (i = ; i <= n; i++)
{
for (j = ; j <= i-; j++)
{
if (p[j] <= p[i] && dp[j] + >= dp[i])
{
dp[i] = dp[j] + ;
ans = max(ans, dp[i]);
}
}
}
printf("%d\n", n-ans);
}
return ;
}
  

gzhu 2013 Good Sequence 解题报告的更多相关文章

  1. USACO Section2.1 Sorting a Three-Valued Sequence 解题报告

    sort3解题报告 —— icedream61 博客园(转载请注明出处)---------------------------------------------------------------- ...

  2. timus 1175. Strange Sequence 解题报告

    1.题目描述: 1175. Strange Sequence Time limit: 1.0 secondMemory limit: 2 MB You have been asked to disco ...

  3. Ducci Sequence解题报告

    A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, ... ,  ...

  4. 【LeetCode】842. Split Array into Fibonacci Sequence 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  5. 【LeetCode】60. Permutation Sequence 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  6. poj 2013 Symmetric Order 解题报告

    题目链接:http://poj.org/problem?id=2013 设长度非递减的字串序列为s[1]...s[n].设计递归子程序print(n),其中n为字串序号,每分析1个字串,n=n-1. ...

  7. LeetCode: Permutation Sequence 解题报告

    Permutation Sequence https://oj.leetcode.com/problems/permutation-sequence/ The set [1,2,3,…,n] cont ...

  8. USACO Section 2.1 Sorting a Three-Valued Sequence 解题报告

    题目 题目描述 给N个整数,每个整数只能是1,2,或3.现在需要对这个整数序列进行从小到大排序,问最少需要进行几次交换.N(1 <= N <= 1000) 样例输入 9 2 2 1 3 3 ...

  9. LeetCode: Longest Consecutive Sequence 解题报告

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

随机推荐

  1. soursTree新建过程.md

    网上博客 https://www.cnblogs.com/tian-xie/p/6264104.html 主要的推送流程 完成所有项目的远程推送工作 点击git工作流选择第二个建立新的版本; 输入发布 ...

  2. Mac 安装配置Mysql

    Mac下安装配置Mysql By 白熊花田(http://blog.csdn.net/whiterbear) 转载需注明出处,谢谢. 下载安装 去官网下载Community版本号的mysql安装文件. ...

  3. hdoj 4828 卡特兰数取模

    Grids Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Sub ...

  4. SQL中Inserted 和Deleted表 以及触发Trigger

    什么是Inserted 和Deleted表 他们有什么用 trigger 的简单实用 1.什么是Inserted 和Deleted表 当插入数据的时候,其实是同时向目的表 和inserted表中插入数 ...

  5. 10934 - Dropping water balloons(DP)

    这道题的思路非常难想. 问你须要的最少实验次数,这是非常难求解的.并且我们知道的条件仅仅有三个.k.n.实验次数 . 所以我们最好还是改变思路,转而求最高所能确定的楼层数 .  那么用d[i][j]表 ...

  6. vs2012 MinGW 编译ffmeg 引用外部库libx264,librtmp

    VS2012如何编译ffmpeg前面已经有文章讲过,本来主要讲述如何引用外部库libx264,librtmp, ffmpeg版本是3.0.2. 1. 下载x264源文件并编译 源码地址是http:// ...

  7. LVDS、MIPI、EDP、VGA、DVI、HDMI、DP3.0(雷电接口)

    1.LVDS 2.mipi 3.EDP:Embedded DisplayPort 4.VGA VGA接口的特性: 1)理论上能够支持2048x1536分辨率画面传输. 2)VGA由于是模拟信号传输,所 ...

  8. ubuntu + lamp + laravel 环境配置

    首先是LAMP 安装顺序是 A(Apache服务器)  M(Mysql) P(Php) 安装apache sudo apt-get install apache2 安装mysql sudo apt-g ...

  9. 监控系统-nagios

    Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设备,打印机等.在系统或服务状态异常发出邮件或短信报警第一 ...

  10. android IPC通信(上)-sharedUserId&amp;&amp;Messenger

    看了一本书,上面有一章解说了IPC(Inter-Process Communication,进程间通信)通信.决定结合曾经的一篇博客android 两个应用之间的通信与调用和自己的理解来好好整理总结一 ...