#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; #define met(a,b) (memset(a,b,sizeof(a)))
#define N 1100
#define INF 0xffffff
struct node
{
int w, s, num;
bool operator < (const node &n)const
{
if(n.w!=w)
return w < n.w;
return s > n.s;
}
}m[N]; int dp[N], pre[N];
int a[N]; int main()
{
int i, j, k=, n, Max=, Index; met(m, );
met(pre, );
met(dp, ); while(scanf("%d%d", &m[k].w, &m[k].s)!=EOF)
{
m[k].num=k;
k++;
} sort(m+, m+k+); n = k-; for(i=; i<=n; i++)
{
dp[i] = ;
for(j=; j<i; j++)
{
if(m[j].w<m[i].w && m[i].s<m[j].s)
{
if(dp[i]<dp[j]+)
{
dp[i] = dp[j] + ;
pre[i] = j;
}
}
if(dp[i]>Max)
{
Max = dp[i];
Index = i;
}
}
} k=;
while(Index)
{
a[k++] = m[Index].num;
Index = pre[Index];
} printf("%d\n", Max);
for(i=k-; i>=; i--)
printf("%d\n", a[i]); return ;
}
 
 
 
 
 
Problem Description
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the speeds are decreasing.
 
Input
Input contains data for a bunch of mice, one mouse per line, terminated by end of file.

The data for a particular mouse will consist of a pair of integers: the first representing its size in grams and the second representing its speed in centimeters per second. Both integers are between 1 and 10000. The data in each test case will contain information for at most 1000 mice.

Two mice may have the same weight, the same speed, or even the same weight and speed.

 
Output
Your program should output a sequence of lines of data; the first line should contain a number n; the remaining n lines should each contain a single positive integer (each one representing a mouse). If these n integers are m[1], m[2],..., m[n] then it must be the case that

W[m[1]] < W[m[2]] < ... < W[m[n]]

and

S[m[1]] > S[m[2]] > ... > S[m[n]]

In order for the answer to be correct, n should be as large as possible.
All inequalities are strict: weights must be strictly increasing, and speeds must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one. 

 
Sample Input
6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900
 
Sample Output
4
4
5
9
7
 
 

FatMouse's Speed (hdu 1160)的更多相关文章

  1. 动态规划----FatMouse’s Speed(HDU 1160)

    参考:https://blog.csdn.net/u012655441/article/details/64920825 https://blog.csdn.net/wy19910326/articl ...

  2. FatMouse's Speed(HDU LIS)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. FatMouse's Speed ~(基础DP)打印路径的上升子序列

    FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take ...

  4. (记忆化搜索) FatMouse and Cheese(hdu 1078)

    题目大意:   给n*n地图,老鼠初始位置在(0,0),它每次行走要么横着走要么竖着走,每次最多可以走出k个单位长度,且落脚点的权值必须比上一个落脚点的权值大,求最终可以获得的最大权值   (题目很容 ...

  5. 2道acm编程题(2014):1.编写一个浏览器输入输出(hdu acm1088);2.encoding(hdu1020)

    //1088(参考博客:http://blog.csdn.net/libin56842/article/details/8950688)//1.编写一个浏览器输入输出(hdu acm1088)://思 ...

  6. HDU 1160 FatMouse's Speed(要记录路径的二维LIS)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. HDU 1160:FatMouse's Speed(LIS+记录路径)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. HDU 1160 FatMouse's Speed (动态规划、最长下降子序列)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. Bestcoder13 1003.Find Sequence(hdu 5064) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b ...

随机推荐

  1. const修饰符用法

    1. 将一个对象设置为不可修改 const int a = 100; 2. 指向const对象的指针 const int* p = 3;可以通过指针来修改指针所指向的值,但是不能通过指针*p修改对像的 ...

  2. Linux硬件相关

    1)查看设备号/厂商号 http://blog.csdn.net/styshoo/article/details/51203881   二.硬件厂商 1)瑞传科技股份有限公司 https://www. ...

  3. taglib简介

    在 JSP最佳实践的 上一期,您学习了一种基于scriptlet的技术,这种技术被用来将上次修改的时间戳添加到JavaServer Page(JSP)文件中.不幸的是,比起它所提供的短期利益,scri ...

  4. 添加exe为windows service服务

    [方法一] 一.介绍 srvany.exe是Microsoft Windows Resource Kits工具集的一个实用小工具,用于将EXE程序作为Windows服务运行.srvany是其注册程序的 ...

  5. R语言读取Hive数据表

    R通过RJDBC包连接Hive 目前Hive集群是可以通过跳板机来访问 HiveServer, 将Hive 中的批量数据读入R环境,并进行后续的模型和算法运算. 1. 登录跳板机后需要首先在Linux ...

  6. String类为什么设计成不可变的

    在Java中将String设计成不可变的是综合考虑到各种因素的结果,需要综合考虑内存.同步.数据结构以安全方面的考虑. String被设计成不可变的主要目的是为了安全和高效. 1)字符串常量池的需要 ...

  7. springmvc相关

    Springmvc的请求注解可分为四类: url请求地址(PathVariable). head请求头(RequestHeader.CookieValue). body请求体(RequestParam ...

  8. 如何用xx-net上youtube

    1.下载https://github.com/XX-net/XX-Net/blob/master/code/default/download.md   里面的稳定版本 2.下载chrome.百度chr ...

  9. .net判断当前时间是否在工作时间段内

    整理代码,判断当前时间是否在配置的工作时间段内,代码如下: public static bool getTimeSpan(string _strWorkingDayAM, string _strWor ...

  10. 【Web】移动端下拉刷新、上拉加载更多插件

    移动网站中常常有的功能:列表的下拉刷新.上拉加载更多 本例介绍一种简单使用的移动端下拉刷新.上拉加载更多插件,下载及参考地址:https://github.com/ximan/dropload 插件依 ...