FatMouse's Speed(HDU LIS)
FatMouse's Speed
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13133 Accepted Submission(s): 5778
Special Judge
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.
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.
6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define Max 10005
int dp[Max],t[Max],ans[Max];
struct node
{
int s,w,n;
}a[Max];
bool cmp(node x,node y)
{
return x.w<y.w;
}
int main()
{
int num;
int i=,j;
freopen("in.txt","r",stdin);
while(scanf("%d%d",&a[i].w,&a[i].s)!=EOF)
{
a[i].n=i;
i++;
}
num=i-;
sort(a+,a+num+,cmp);
/* for(i=1;i<=num;i++)
{
cout<<a[i].w<<" "<<a[i].s<<" "<<a[i].n<<endl;
}*/
for(i=;i<Max;i++)
{
dp[i]=;
t[i]=;
}
for(i=;i<=num;i++)
{
for(j=;j<i;j++)
{
if(a[i].s<a[j].s&&a[i].w!=a[j].w&&(dp[j]+)>dp[i])
{
dp[i]=dp[j]+;
t[i]=j;
}
}
}
int maxn=dp[num],index=num;
for(i=;i<=num;i++)
if(dp[i]>maxn)
{
index=i;
maxn=dp[i];
}
ans[maxn]=a[index].n;
// cout<<ans[maxn]<<endl;
index=t[index];
for(i=maxn-;i>=;i--)
{
ans[i]=a[index].n;
// cout<<ans[i]<<endl;
index=t[index];
}
cout<<maxn<<endl;
for(i=;i<=maxn;i++)
cout<<ans[i]<<endl;
}
FatMouse's Speed(HDU LIS)的更多相关文章
- FatMouse's Speed (hdu 1160)
#include <iostream> #include <cstdio> #include <cstring> #include <algori ...
- 动态规划----FatMouse’s Speed(HDU 1160)
参考:https://blog.csdn.net/u012655441/article/details/64920825 https://blog.csdn.net/wy19910326/articl ...
- FatMouse's Speed ~(基础DP)打印路径的上升子序列
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take ...
- (记忆化搜索) FatMouse and Cheese(hdu 1078)
题目大意: 给n*n地图,老鼠初始位置在(0,0),它每次行走要么横着走要么竖着走,每次最多可以走出k个单位长度,且落脚点的权值必须比上一个落脚点的权值大,求最终可以获得的最大权值 (题目很容 ...
- 2道acm编程题(2014):1.编写一个浏览器输入输出(hdu acm1088);2.encoding(hdu1020)
//1088(参考博客:http://blog.csdn.net/libin56842/article/details/8950688)//1.编写一个浏览器输入输出(hdu acm1088)://思 ...
- 2021.12.06 P2501 [HAOI2006]数字序列(动态规划+LIS)
2021.12.06 P2501 [HAOI2006]数字序列(动态规划+LIS) https://www.luogu.com.cn/problem/P2501 题意: 现在我们有一个长度为 n 的整 ...
- 题解报告:hdu 1160 FatMouse's Speed(LIS+记录路径)
Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove th ...
- HDU 1160 FatMouse's Speed(要记录路径的二维LIS)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1160:FatMouse's Speed(LIS+记录路径)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- Angular2 - Starter - Pipes, Custom Pipes
在Angular2 模板中,我们在显示数据时,可以使用通道将数据转换成相应的格式的值的形式来显示,而且这不改变源数据.比如,我们可以使用date通道来转换时间显示的格式: {{date | date: ...
- Tk::Table
<pre name="code" class="python"># DESCRIPTION # Tk::Table is an all-perl w ...
- Eclipse + CDT + YAGARTO + J-Link,STM32开源开发环境搭建与调试
Eclipse+CDT+YAGARTO+J-Li:开源开发环境搭建与调试:作者:Chongqing:邮箱:ycq.no1@163.com:文档版本:V1.0:发布日期:2014-08-04:前言:此文 ...
- 实用的VIM配置文件
VIM配置文件名为.vimrc,默认在用户根目录下,或者在命令模式下输入:version可以获取配置文件路径. 在VIM命令行下输入options,然后回车,可以查看VIM所有的参数选项. 双引号&q ...
- C#中通过位运算实现多个状态的判断
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- python之路-模块安装 paramiko
paramiko介绍(全是洋文,看不懂啊,赶紧有道翻译吧,等有朝一日,我去报个华尔街): "Paramiko" is a combination of the esperanto ...
- sql执行顺序整理
sql的执行顺序,是优化sql语句执行效率必须要掌握的.各个数据库可能有细小的差别,但大体顺序是相同的,这里只做大致说明. 一.总体执行顺序 在sql语句执行之前,还有SQL语句准备执行阶段,这里不做 ...
- mysql保存emoji表情(微信开发用户昵称..)
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for colum n 'name' at row 1 at c ...
- ASP.Net请求处理机制初步探索之旅 - Part 1 前奏(转)
在读本文之前建议先阅读IIS架构:http://www.cnblogs.com/tiantianle/p/5079932.html 不管是ASP.Net WebForm还是ASP.Ne ...
- 关于Http协议(2)--转载
原文链接:http://www.cnblogs.com/mcad/ HTTP工作原理图 请求报文 1.请求报文长什么样? Chrome核心的请求报文 2.报文结构 3.报文头部每个字段的意义 //从 ...