参考: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. 再学UML-UML用例建模解析(三)

    2. 编写用例文档 绘制用例图只是完成了用例建模最基本也是最简单的一步,用例建模的核心在于编写用例文档,用例文档又称为用例规约或用例描述.顾名思义,用例文档是用于描述用例的文档,每一个用例对应于一个用 ...

  2. 第五章 LED的魔性操作

    想必大家都见过城市里漂亮的led广告牌吧,这一节我将带大家学习这些LED广告牌最基本的实现原理. 初识LED 接线方法:D1~D8从接23~37号数字端口,v1和前面的针头分别接41号和39号数字端口 ...

  3. pl/sql 存储过程执行execute immediate 卡住

    在存储过程中,执行了create table.update table.insert into table 但是在使用pl/sql的存储过程调试的时候,一有问题就直接卡住(标识:执行中.....) 后 ...

  4. 716. Max Stack (follow up questions for min stack)

    Design a max stack that supports push, pop, top, peekMax and popMax. push(x) -- Push element x onto ...

  5. oracle spatial下对wkt字符串操作遇到srid的解决方案

    <span style="font-size:18px;">select fid from vgnss where SDO_WITHIN_DISTANCE(geom,  ...

  6. 编程思想的理解(POP,OOP,SOA,AOP)

    http://blog.csdn.net/hawksoft/article/details/7021435 1)POP--面向过程编程(Process-oriented programming ):面 ...

  7. Codeforces Round #521 (Div. 3) D. Cutting Out 【二分+排序】

    任意门:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory ...

  8. 菜鸟笔记 -- Chapter 6.1 面向对象概述

    6.1 面向对象概述 在程序开发的初期人们使用结构化开发语言,但是随着时间的流逝,软件的规模越来越庞大,结构化语言的弊端逐渐暴露出来,开发周期被无限制拖延,产品质量也不尽如人意,人们终于发现结构化语言 ...

  9. 9.异常Exception

    9.1 异常概述 package exception; /* * 异常:程序运行的不正常情况 * * Throwable: 异常的超类 * |-Error * 严重问题,这种问题我们通过异常处理是不能 ...

  10. 一个logstash引发的连环案,关于logstash提示:Reached open files limit: 4095, set by the 'max_open_files' option or default, files yet to open: 375248

    不多说,直接上问题.版本logstash-2.4.0,启动后提示错误: !!! Please upgrade your java version, the current version '1.7.0 ...