hdu 2881(LIS变形)
Jack's struggle
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1418 Accepted Submission(s): 471
The
battlefield was divided into a grid of n*n, this team can be
air-dropped at any place on time 0. In every time unit after landing,
they can go to the grid left, right, up or down to the current grid, or
they can just stay.
On their mission list, each mission is described
as three integers: t, r and c, represents a task that must be completed
exactly at time t on the grid (r, c).
Obviously, with limits of time, not all missions can be done.
The captain, Jack, struggling making decisions, wants to know how many missions they can complete at most.
For each case:
* The first line contains two integers n and m, 1<=n<=1000,
1<=m<=10000, n represents the size of the battlefield and m
represents the number of missions on the list.
* Following m lines, each one describes a mission using three integers, t, r and c.
No two missions have the same t, r and c.
The input is terminated by n=m=0.
1 1 1
2 2 2
0 0
问输入的这些询问中最多达到多少个点.
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int M = ;
struct grid{
int t,r,c;
}g[M];
int dp[M];
int cmp(grid a,grid b){
return a.t < b.t;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF,n+m){
for(int i=;i<=m;i++){
scanf("%d%d%d",&g[i].t,&g[i].r,&g[i].c);
}
sort(g+,g+m+,cmp);
int ans = -;
for(int i=;i<=m;i++){
dp[i]=;
for(int j=;j<i;j++){
int usetime = abs(g[i].r-g[j].r)+abs(g[i].c-g[j].c);
if(usetime<=abs(g[j].t-g[i].t)&&dp[j]+>dp[i]) dp[i] = dp[j]+;
}
ans = max(ans,dp[i]);
}
printf("%d\n",ans);
}
return ;
}
hdu 2881(LIS变形)的更多相关文章
- hdu 1087(LIS变形)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Super Jumping! Jumping! Jumping!(hdu 1087 LIS变形)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 5256 LIS变形
给一个数列,问最少修改多少个元素使数列严格递增.如果不是要求“严格”递增,那就是求最长不降子序列LIS,然后n-LIS就是答案.要严格递增也好办,输入的时候用每个数减去其下标处理一下就行了. /* * ...
- hdu 5125(LIS变形)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5125 题解: 这个题dp[i][0],dp[i][1]数组分别记录在第i个位置取a[i]和b[i]时 ...
- 九度 1557:和谐答案 (LIS 变形)
题目描述: 在初试即将开始的最后一段日子里,laxtc重点练习了英语阅读的第二部分,他发现了一个有意思的情况.这部分的试题最终的答案总是如下形式的:1.A;2.C;3.D;4.E;5.F.即共有六个空 ...
- UVA 437 巴比伦塔 【DAG上DP/LIS变形】
[链接]:https://cn.vjudge.net/problem/UVA-437 [题意]:给你n个立方体,让你以长宽为底,一个个搭起来(下面的立方体的长和宽必须大于上面的长和宽)求能得到的最长高 ...
- HDU 5489 Removed Interval (LIS变形)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5489 给你n个数,要删去其中连续的L个,问你删去之后的LIS最大是多少? 我们先预处理出以i下标为开头 ...
- HDU 1069 Monkey and Banana DP LIS变形题
http://acm.hdu.edu.cn/showproblem.php?pid=1069 意思就是给定n种箱子,每种箱子都有无限个,每种箱子都是有三个参数(x, y, z)来确定. 你可以选任意两 ...
- hdu 5256 序列变换 (LIS变形)
序列变换 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
随机推荐
- React获取组件实例
1. 直接new Component() 组件本身也是class,可以new,这样的组件实例意义不大 componentInstance = new Component(); 2. ReactDOM. ...
- contOS镜像快速加载到本地虚拟机软件
无需任何配置,只要两步: 1.首先打开 虚拟机软件VMware 2.然后打开镜像目录,找到后缀名为 .vmx 的文件,双击,即可. 会自动 挂载好,如下图:
- 在局域网中基于Windows文件共享的git环境搭建
本文的思想是在局域网中用一台电脑作为服务器,在其中建立一个文件夹,作为总的公开版本库.然后将这个文件夹共享,使其他客户机都可以访问,从而进行代码的管理. 一.下载安装文件 1.git核心: git-f ...
- CentOS 6.5 下 QT4 连接 mysql 数据库的步骤
QT4 的安装请参考: CentOS 6.5 下安装 QT 4 mysql 的安装请参考: CentOS 6.5 下安装配置 mysql 1. 预防万一,先安装一下mysql-devel(一定要装!) ...
- bnuoj25660 Two Famous Companies
题目链接:https://www.bnuoj.com/v3/problem_show.php?pid=25660 这个二分真的是烧脑QAQ,想了一晚上才懂了一个大概. 首先,整体思路是二分,直观上感受 ...
- layer 限定时间消失
默认tips层几秒后自动关闭.请问如何实现类似页面层时,点击页面层外部遮罩手动关闭的效果? 下面我加了time: 20000 时间控制在20秒后自动关闭,但是显得比较呆板,不如用户手动点击关闭来的灵活 ...
- mysql Innodb索引
基本概念 对于mysql目前的默认存储引擎Innodb来说,索引分为2个,一个是聚集索引,一个是普通索引(也叫二级索引). 聚集索引:聚集索引的顺序和数据在磁盘的顺序一致,因此查询时使用聚集索引,效率 ...
- (第三章,第四章)http报文内的http信息,返回结果的http状态码
第三章 http报文内的http信息 用于http协议交互的信息被称为http报文,包括请求报文和响应报文. 1.编码提升传输速率,在传输时编码能有效的处理大量的访问请求.但是编码的操作是计算机完成的 ...
- java collection (二)
1.集合的概念: (1)现实生活中:很多的事物凑在一起. (2)数学中的集合:具有共同属性的事物的总体. (3java 中的集合类: 是一种工具类,就像是容器,存储任意数量的具有共同属性的对象.(集合 ...
- 【BZOJ1093】【ZJOI2007】最大半联通子图 [DP][Tarjan]
最大半连通子图 Time Limit: 30 Sec Memory Limit: 162 MB[Submit][Status][Discuss] Description 一个有向图G=(V,E)称为 ...