A - 最少拦截系统 (最长上升子序列)
A - 最少拦截系统
怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统.
8 389 207 155 300 299 170 158 65
2
#include <stdio.h>
#include <cstring>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
const int Maxn = 30010;
int dp[Maxn],a[Maxn];
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
for(int i=0; i<n; i++)
scanf("%d",&a[i]);
int ans=0;
for(int i=0; i<n; i++)
{
dp[i]=1;
for(int j=0; j<i; j++)
{
if(a[j]<a[i])
dp[i]=max(dp[i],dp[j]+1);//LIS 状态转移方程
} //dp[i]以a[i]结尾的上升子序列的长度
ans=max(dp[i],ans);
}
// int sum=0;
/* for(int i=0; i<n; i++)
{
if(sum<dp[i])
sum=dp[i];
}
printf("%d\n",sum); */
printf("%d\n",ans);
} return 0;
}
A - 最少拦截系统 (最长上升子序列)的更多相关文章
- HDU 1257 最少拦截系统 最长递增子序列
HDU 1257 最少拦截系统 最长递增子序列 题意 这个题的意思是说给你\(n\)个数,让你找到他最长的并且递增的子序列\((LIS)\).这里和最长公共子序列一样\((LCS)\)一样,子序列只要 ...
- hdu 1257 最少拦截系统 求连续递减子序列个数 (理解二分)
最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- (最长不降子序列)最少拦截系统 -- hdu -- 1257
http://acm.hdu.edu.cn/showproblem.php?pid=1257 最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memo ...
- POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)
Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...
- HDU 1257 最少拦截系统【最长上升子序列】
解题思路:可以转化为求最长上升子序列来做,还是可以用an与按升序排列后的an求LCS来做,为防止超时,用滚动数组优化一下就可以了. 最少拦截系统 Time Limit: 2000/1000 MS (J ...
- HDU 1257 最少拦截系统(Dilworth定理+LIS)
最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- 最少拦截系统(杭电1257)(DP)+(贪心)
最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- HDU 1257 最少拦截系统(贪心 or LIS)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1257 最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 1257 最少拦截系统(动态规划 / 贪心)
最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
随机推荐
- Node爬虫之——使用async.mapLimit控制请求并发
一般我们在写爬虫的时候,很多网站会因为你并发请求数太多当做是在恶意请求,封掉你的IP,为了防止这种情况的发生,我们一般会在代码里控制并发请求数,Node里面一般借助async模块来实现. 1. asy ...
- 创建django的8大步骤xxx.setAttribute('name', 'user'); 添加属性和值 xxx.attr('name') 查看属性的值 $(xxx).addClass 添加样式 $().after() 添加在标签后面
第一步.创建django 方法一:django-admin startproject 方法二: 直接在python上创建 第二步:创建工程名cmdb python manage.py startapp ...
- Android bitmap转byte
逆转start协议输出 private static byte[] bitmap2byte(Bitmap bmp) throws Exception{ return bitmap2byte(bmp, ...
- [/usr/local/openssl//.openssl/include/openssl/ssl.h] Error 127
/bin/sh: line 2: ./config: No such file or directorymake[1]: *** [/usr/local/ssl/.openssl/include/op ...
- [leetcode]621. Task Scheduler任务调度
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where diffe ...
- MVC架构思想
- Java初学者不得不知的概念,JDK,JRE,JVM的区别?(转)
JVM(Java Virtual Machine Java虚拟机)可以理解为是一个虚拟出来的计算机,具备着计算机的基本运算方式,它主要负责将java程序生成的字节码文件解释成具体系统平台上的机器指令. ...
- HDU 2044 一只小蜜蜂...(递推,Fibonacci)
题意:中文题. 析:首先要想到达第 n 个蜂房,那么必须经 第 n-1 或第 n-2 个蜂房,那么从第 n-1 或第 n-2 个蜂房到达第 n 个,都各自有一条路线, 所以答案就是第 n-1 + 第 ...
- Knowing how all your components work together: distributed tracing with Zipkin
转自: http://aredko.blogspot.com/2014/02/knowing-how-all-your-components-work.html In today's post we ...
- ZOJ2201 No Brainer 2017-04-16 19:21 54人阅读 评论(0) 收藏
No Brainer Time Limit: 2 Seconds Memory Limit: 65536 KB Zombies love to eat brains. Yum. Input ...