参考: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. 【Leetcode】【Easy】Minimum Depth of Binary Tree

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  2. php提示undefined index的几种解决方法

    平时用$_post[''],$_get['']获取表单中参数时会出现Notice: Undefined index: -------- 我们经常接收表单POST过来的数据时报Undefined ind ...

  3. 为什么使用中间件下载时总是收到警告消息Object is in status Wait

    在使用中间件从ERP下载对象时,正常情况下应该看到如下提示消息: 然而有时遇到的是黄色的警告消息:Object is in status Wait. 如何自己排错呢?在函数SMOF0_INIT_DNL ...

  4. google Cayley图谱数据库初试

    一.安装 mkdir cayley cd cayley mkdir src export GOPATH=$(pwd) go get github.com/google/cayley go build ...

  5. HDU 3336 KMP

    题意:求每一个前缀,跟前缀相同的每个子串. 此题:网上很多都是假程序,不过也AC了,的确我测试几个案例之后的的确确是存在这个问题. 分析:每一个前缀,可以考虑KMP,f失配指针,如何求得它出现了多少次 ...

  6. CF873F 【Forbidden Indices】

    还有这么板子的题? 和你谷上后缀自动机的板子基本一样,区别就是之后这个位置是\(0\)才计入贡献 代码 #include<iostream> #include<cstdio> ...

  7. 【luogu P3410 拍照】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3410 这个题就是求一个最大权闭合图 在一个图中,一些点构成一个集合,且集合中的出边指向的终点也在这个集合中, ...

  8. H5新增API和操作DOM

    博客原文:https://dobinspark.com.cn/ H5-dom扩展 获取元素 document.getElementsByClassName ('class'); //通过类名获取元素, ...

  9. [Linux]文件浏览

    1.使用file命令查看文件中数据的类型 [oracle@linuxforlijiaman Desktop]$ ls linux oracle.txt test.png [oracle@linuxfo ...

  10. LINUX日志的错误等级

    LINUX日志的错误等级 - CSDN博客 https://blog.csdn.net/solmyr_biti/article/details/50634533讯息等级 系统将讯息分为七个主要的等级, ...