HDU
来源:互联网 发布:python kgram算法 编辑:程序博客网 时间:2024/06/08 08:12
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the speeds are decreasing.
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
and
S
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.
6008 13006000 2100500 20001000 40001100 30006000 20008000 14006000 12002000 1900
44597
#include<cstdio>#include<cstring>#include<algorithm>#define max_n 2010typedef long long LL;using namespace std; int dp[max_n],v[max_n];struct node{int a;int b;int c;int d;}s[max_n];bool cmp1(node x,node y){ return x.a>y.a;}int main(){int n,m,u=1;while(scanf("%d %d",&n,&m)!=EOF){s[u].a=n;s[u].b=m;s[u].c=u;s[u].d=0;u++;}sort(s+1,s+u,cmp1);s[0].a=0x3f3f3f3f;s[0].b=0;s[0].c=0;s[0].d=0;int ans=0;for(int i=1;i<u;i++){dp[i]=0;for(int j=0;j<i;j++){if(s[i].a<s[j].a && s[i].b>s[j].b){if(dp[i]<=dp[j]+1){dp[i]=dp[j]+1;s[i].d=j;if(dp[i]>dp[ans]) ans=i;}}}}printf("%d\n",dp[ans]);while(s[ans].d!=0){printf("%d\n",s[ans].c);ans=s[ans].d;}printf("%d\n",s[ans].c);return 0;}
阅读全文
1 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- tomcat 的配置
- python 初学者的第一天
- 我为什么选择go语言
- CRM工具简介
- React-Native自定义单选radio
- HDU
- dataframe中更改列属性的方法
- 绕开客户端JS验证
- java语言基础(72)——静态导入
- C++资源之不完全导引(完整版)
- 二叉树相关(抄袭不能
- Kafka整体结构图、Consumer与topic关系、Kafka消息分发、Consumer的负载均衡、Kafka文件存储机制、Kafka partition segment等(来自学习资料)
- interlij idea创建给Web项目添加Mybatis
- 技术性网址