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) ...
随机推荐
- 新闻动态切换图片html(flash)
效果图: 代码: <table id="table_zi"> <tr> <td class="width330"> < ...
- sql server高效分页控件及c#调用实例
第一.首先在sqlserver中创建一个存储过程 USE [BZY] GO /****** 对象: StoredProcedure [dbo].[up_ProcCustomPage2005_New] ...
- java读取property文件
property文件中: url = jdbc:mysql://localhost:3306/resume user= root pwd = 123 java代码读取: packa ...
- VLSI和ASIC的区别(转)
VLSI和ASIC是不同的两个概念 VLSI(Very Large Scale Integrate circuit)是指集成电路的规模,有时也指制造集成电路所使用的工艺,VLSI工艺一般都在1um以下 ...
- 关于PowerShell中的命令的别名
cmdlets的别名,有利于使用传统的cmd的方式 或者使用 bash的方式的人员,更加方便的使用使用频率较高的命令. 以下是从 别名中获取的内置的别名. PS C:\> Get-Alias * ...
- Friendly number
Friendly number Long numbers can be made to look nicer, so let’s write some code to do just that. Yo ...
- UML--核心元素之业务实体
如果说参与者和用例描述了我们在这个问题领域中达到什么样的目标,那么业务实体就描述了我们使用什么来达到业务目标以及通过什么来记录这个业务目标. 如果把问题领域比喻成一幢大楼的话,业务实体就是构成这幢大楼 ...
- Poj1741-Tree(树分治)
题意:找树上有多少对距离小于K的对数解析:树分治模板题,见注释 代码 #include<cstdio> #include<cstring> #include<string ...
- 简述tcp协议对http性能的影响及优化
当网站服务器并发连接达到一定程度时,你可能需要考虑服务器系统中tcp协议设置对http服务器的影响. tcp相关延时主要包括: 1.tcp连接时建立握手: 2.tcp慢启动拥塞控制: 3.数据聚集的N ...
- sem_timedwait的用法
#include <semaphore.h> int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); Link ...