FatMouse's Speed (hdu 1160)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; #define met(a,b) (memset(a,b,sizeof(a)))
#define N 1100
#define INF 0xffffff
struct node
{
int w, s, num;
bool operator < (const node &n)const
{
if(n.w!=w)
return w < n.w;
return s > n.s;
}
}m[N]; int dp[N], pre[N];
int a[N]; int main()
{
int i, j, k=, n, Max=, Index; met(m, );
met(pre, );
met(dp, ); while(scanf("%d%d", &m[k].w, &m[k].s)!=EOF)
{
m[k].num=k;
k++;
} sort(m+, m+k+); n = k-; for(i=; i<=n; i++)
{
dp[i] = ;
for(j=; j<i; j++)
{
if(m[j].w<m[i].w && m[i].s<m[j].s)
{
if(dp[i]<dp[j]+)
{
dp[i] = dp[j] + ;
pre[i] = j;
}
}
if(dp[i]>Max)
{
Max = dp[i];
Index = i;
}
}
} k=;
while(Index)
{
a[k++] = m[Index].num;
Index = pre[Index];
} printf("%d\n", Max);
for(i=k-; i>=; i--)
printf("%d\n", a[i]); return ;
}
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.
FatMouse's Speed (hdu 1160)的更多相关文章
- 动态规划----FatMouse’s Speed(HDU 1160)
参考:https://blog.csdn.net/u012655441/article/details/64920825 https://blog.csdn.net/wy19910326/articl ...
- FatMouse's Speed(HDU LIS)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 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)://思 ...
- 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) ...
- HDU 1160 FatMouse's Speed (动态规划、最长下降子序列)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Bestcoder13 1003.Find Sequence(hdu 5064) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b ...
随机推荐
- Jenkins构建.net项目
一.环境搭建 1.安装所需软件 Jenkins\JDK\GIT\VS\IIS\nginx(可选) 1.1 安装iis服务: 控制面板—>程序和功能—>启用或关闭windows功能,勾选所有 ...
- mybatis入门--单表的增删改操作
单表的增加操作 前面我们看了如何搭建mybatis框架以及查询操作,这里我们说下如何使用mybatis进行增加用户的操作.首先是在user.xml文件中添加insert的方法.代码如下 <!-- ...
- Ionic3--数据存储
1.使用sqlite cordova plugin add cordova-sqlite-storage --save npm install --save @ionic/storage (本地存储) ...
- andorid 多线程handler用法
.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...
- HDU_2136
#include <iostream> #include <stdio.h> #include <math.h> #include <algorithm> ...
- Site.ForProductsOfApple
1. cultofmac http://www.cultofmac.com/ 2. imore http://www.imore.com/ 3. osxdaily http://osxdaily.co ...
- javascript 高级程序设计 二
这里我们直接进入主题: 在JS刚刚开始的时候,必须面临一个问题,那就是如何使的JS的加载和执行不会影响web核心语言HTML的展示效果,和HTML和谐共存. 在这个背景下<script>标 ...
- BZOJ1912或洛谷3629 [APIO2010]巡逻
一道树的直径 BZOJ原题链接 洛谷原题链接 显然在原图上路线的总长为\(2(n-1)\). 添加第一条边时,显然会形成一个环,而这条环上的所有边全部只需要走一遍.所以为了使添加的边的贡献最大化,我们 ...
- 美食类Web原型制作分享-Taste
Taste是国外知名的美食类网站,为人们提供丰富的美食菜单,帮助人们更好的享受美食带来的快乐.网站采用图文结合的排版方式,有固定顶部导航栏的交互功能等. 本原型由国产原型工具Mockplus和团队协作 ...
- mybatis的批量操作
foreach关键字: 批量查找/删除:用where id in<foreach> (xxx,yyy,zzz ...)</foreach> 批量更新:需要开启批量sql,比如d ...