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

https://blog.csdn.net/wy19910326/article/details/7232308

https://blog.csdn.net/weizhuwyzc000/article/details/45823031

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
using namespace std;
const int N=1e3+;
int dp[N];
struct node
{
int w,s,n;
}m[N];
int cmp(struct node x,struct node y)
{
if (x.w==y.w)
{
return x.s>y.s;
}
else
{
return x.w<y.w;//注意排序要求!
}
}
int main()
{
int w,s,i=;
// freopen("bin.txt","r",stdin);
while (cin>>w>>s)
{
m[i].w=w,m[i].s=s,m[i].n=i;
dp[i]=;
i++;
sort(m+,m+i,cmp);
}
int maxn,maxd=;
for (int j=;j<i;j++)//更新dp数组
{
for (int k=;k<j;k++)
{
if (m[k].w<m[j].w&&m[k].s>m[j].s)
{
dp[j]=max(dp[j],dp[k]+);
if (dp[j]>maxd)
{
maxd=dp[j];
maxn=j;
}
}
}
}
stack<int> st;
st.push(m[maxn].n);
for (int j=maxn-;j>=;j--)//用栈存路径
{
if (j<maxn&&dp[j]==dp[maxn]-)
{
st.push(m[j].n);
maxn=j;
}
}
cout<<st.size()<<endl;
while (!st.empty())
{
cout<<st.top()<<endl;
st.pop();
} return ;
}

动态规划----FatMouse’s Speed(HDU 1160)的更多相关文章

  1. (最长上升子序列 并记录过程)FatMouse's Speed -- hdu -- 1160

    http://acm.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Other ...

  2. ZOJ 1108 FatMouse's Speed (HDU 1160) DP

    传送门: ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=108 HDU :http://acm.hdu.edu.cn/s ...

  3. FatMouse's Speed HDU - 1160 最长上升序列, 线性DP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> usi ...

  4. HDU - 1160 FatMouse's Speed 动态规划LIS,路径还原与nlogn优化

    HDU - 1160 给一些老鼠的体重和速度 要求对老鼠进行重排列,并找出一个最长的子序列,体重严格递增,速度严格递减 并输出一种方案 原题等于定义一个偏序关系 $(a,b)<(c.d)$ 当且 ...

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

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

  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 (DP)

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

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

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

  9. HDU 1160 FatMouse&#39;s Speed(DP)

    题意  输入n个老鼠的体重和速度   从里面找出最长的序列  是的重量递增时速度递减 简单的DP  令d[i]表示以第i个老鼠为所求序列最后一个时序列的长度  对与每一个老鼠i  遍历全部老鼠j  当 ...

随机推荐

  1. C#发送电子邮件 (异步) z

    ///验证电子邮件的正则表达式   string emailStr = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([ ...

  2. day3-购物车小程序

    1.要求 启动程序后,让用户输入工资,然后打印商品列表 允许用户genuine商品编号购买商品 用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒还有多少 可随时退出,退出时,打印已购买商品和余 ...

  3. 管道(Pipelines)模型

    Pipeline模型最早被使用在Unix操作系统中.据称,假设说Unix是计算机文明中最伟大的发明,那么,Unix下的Pipe管道就是尾随Unix所带来的还有一个伟大的发明[1].我觉得管道的出现,所 ...

  4. pthread 的几个结构体

    http://blog.csdn.net/yangzhongxuan/article/details/7397139 /* Copyright (C) 2002,2003,2004,2005,2006 ...

  5. css relative

    一.relative和absolute相煎关系 relative限制absolute 1.限制left/top/right/bottom定位 如果父元素有relative,只能根据父元素进行定位 2. ...

  6. 【转】应用程序的入口是ActivityThread

    ActivityThread运行框架 在分析中,我们可以看到真正对应应用进程的不是Application而是ActivityThread.我们从实际的应用堆栈可以看到: NavitiveStart.m ...

  7. STL - set【集合】

    参考:http://www.cplusplus.com/reference/set/set/ 一.set 是按特定顺序存储唯一元素的容器 实现是一种非常高效的平衡检索二叉树:红黑树(Red-Black ...

  8. Blog 使用Jsoup解析出html中的img元素

    Jsoup主页:http://jsoup.org/ 在Blog.java 加入 private List<String> imageList=new LinkedList<Strin ...

  9. mybatis学习记录七——延迟加载

    14       延迟加载 14.1     什么是延迟加载 resultMap可以实现高级映射(使用association.collection实现一对一及一对多映射),association.co ...

  10. WebNotes(PHP、css、JavaScript等)

    1. 数据库编码格式 gb-2312仅支持简体中文,GBK支持简体.繁体中文,utf-8通用程度最高. 2. HTTP请求方法 get方法请求时,会将传输的数据跟在链接后“显式地”发送,受限于链接长度 ...