FatMouse's Speed——J
J. FatMouse's Speed
Input
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.
Output
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.
Sample Input
6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900
Sample Output
4
4
5
9
7
题意:
要求找到的体重递增,速度递减的老鼠,并且输出最长的长度数,而且输出各自的序列数。(Special Judge 说明答案不唯一,只要输出的答案正确就可以)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int num,w,s;
}a[];
int cmp(node c,node d) {return c.w<d.w;}
int x,y,k,t[],r[];
int main()
{
int i,j,L,p=,ant=,er=;
k=;
memset(t,,sizeof(t));
while(cin>>x>>y)
{
a[k].num=k+;
a[k].w=x;
a[k].s=y;
k++;
}
sort(a,a+k,cmp);
for(i=;i<k;i++) t[i]=;
for(i=;i<k;i++)
{
for(j=;j<i;j++)
{
if(a[j].s>a[i].s&&a[j].w<a[i].w&&t[i]<t[j]+)
t[i]+=;
}
}
for(i=;i<k;i++) p=max(p,t[i]);
cout<<p<<endl;
for(i=;i<k;i++)
{
if(p==t[i]) j=i;
}
int temp=j;
r[er++]=a[j].num;
for(L=j-;L>=;L--)
{
if(t[L]+==t[j]&&a[L].s>a[temp].s)
{
ant++;
r[er++]=a[L].num;
t[j]=t[L];
temp=L;
}
if(ant==p) break;
}
for(i=er-;i>;i--) cout<<r[i]<<endl;
return ;
}
FatMouse's Speed——J的更多相关文章
- J - FatMouse's Speed
p的思路不一定要到最后去找到ans:也可以设置成在中间找到ans:比如J - FatMouse's Speed 这个题,如果要是让dp[n]成为最终答案的话,即到了i,最差的情况也是dp[i-1],就 ...
- 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 (DP)
FatMouse's Speed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- 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's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- zoj 1108 FatMouse's Speed 基础dp
FatMouse's Speed Time Limit: 2 Seconds Memory Limit:65536 KB Special Judge FatMouse believe ...
- HDU 1160:FatMouse's Speed(LIS+记录路径)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- (最长上升子序列 并记录过程)FatMouse's Speed -- hdu -- 1160
http://acm.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Other ...
- zoj 1108 FatMouse's Speed 基础dp
FatMouse's Speed Time Limit: 2 Seconds Memory Limit:65536 KB Special Judge FatMouse believe ...
随机推荐
- Jquery实现花瓣随机飘落(收藏自慕课网)
这个东西实际上慕课的艾伦大大先写的. 然后别人推荐给我,偶一直收藏着,然后偶再推荐给偶的队友们,然后呢,这帮货就懒得都不肯去看... 接着今天受伤在家就提出来了一点东西放在我博客顶上... 然后艾伦的 ...
- 莫比乌斯环-vtkTriangleStrip
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- C#模拟鼠标键盘控制其他窗口(一)
编写程序模拟鼠标和键盘操作可以方便的实现你需要的功能,而不需要对方程序为你开放接口.比如,操作飞信定时发送短信等.我之前开发过飞信耗子,用的是对飞信协议进行抓包,然后分析协议,进而模拟协议的执行,开发 ...
- JavaScript方法call、apply、caller、callee、bind的使用详解及区别
一.call 方法 调用一个对象的一个方法,以另一个对象替换当前对象(其实就是更改对象的内部指针,即改变对象的this指向的内容). 即 “某个方法”当做“指定的某个对象”的“方法”被执行. Js代 ...
- MySQL关键字
MySQL关键字 ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE BEFORE BETWEEN BIGINT BINARY BLOB BOTH BY CALL ...
- /etc/rc.d/rc与/etc/rc.d/init.d的关系
在这里先解释一下 /etc/rc.d/init.d 里面放的都是什么东西.这个目录存放的是一些脚本,一般是Linux以rpm包安装时设定的一些服务的启动/关闭脚本.系统在安装时装了好多rpm包,这里面 ...
- C和指针 第三章 四种作用域
代码块作用域: 任何位于一对花括号之间是一个代码块,代码块内声明的标识符具有代码块作用域,嵌套代码块内,内部变量会屏蔽外部相同标示的标示符,非嵌套代码块,不会同时处于活动状态所以不会屏蔽. int m ...
- 超简单,安卓模拟器手动root
本文转载自:http://quantoubao.blog.163.com/blog/static/2083211702013870501987/ 安装Android SDK安卓模拟器的方法很简单,网上 ...
- JVM相关参数的采集
1.以-jar方式启动jar包: java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=40100 ...
- UVa2521
理解:max 记录的是有大牌的个数 mid 是有中断 而造成的不确定 我理解是一个间断点以下的 数和一个间断点抵消 在前面没有间断的情况下 才能确定这张牌稳赢 #include<iostrea ...