HDU1160 FatMouse's Speed —— DP】的更多相关文章

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17386    Accepted Submission(s): 7694Special Judge Problem Description…
FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1160 Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on…
题目链接: https://vjudge.net/contest/68966#problem/J 找最长子串并且记录路径. TLE代码: #include<iostream> #include<string> #include<algorithm> #include<cstring> #include<stdio.h> using namespace std; # define inf 0x3f3f3f3f # define maxn 20000…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1160 学的东西还是不深入啊,明明会最长上升子序列,可是还是没有A出这题,反而做的一点思路没有,题意就不多说了,真是怀疑了为什么做这题的时候竟然想用nlog(n)的那个算法, 根本不可能有解啊,真想抽自己一下,最后无奈看了题解,发现他们写的非常棒,记录路径仅用一个数组就可以实现,可惜我没有想到啊,还是做题不深入啊. 首先需要排一下序. 代码如下: #include <iostream> #include…
题目大意:读入一些数(每行读入$w[i],s[i]$为一组数),要求找到一个最长的序列,使得符合$w[m[1]] < w[m[2]] < ... < w[m[n]]$且$s[m[1]] > s[m[2]] > ... > s[m[n]]$,并输出每组数在读入时的顺序(具体见原题目). 思路:先根据w从小到大排序,再求最长下降子序列,DP时保存路径,最后递归输出路径. C++ Code: #include<cstdio> #include<algorit…
J - FatMouse's Speed DP的题写得多了慢慢也有了思路,虽然也还只是很简单的DP. 因为需要输出所有选择的老鼠,所以刚开始的时候想利用状态压缩来储存所选择的老鼠,后面才发现n太大1<<1000根本存不下来... 思路的话其实也不难,把体重排序之后,对速度求一个最长下降子序列即可. 对于每一次求最长有序子序列,只需要全部遍历一遍,遍历的时候,将该位置作为所选择序列的最后一个元素,DP[i]即为该序列的最大长度. 代码: // Created by CAD on 2019/10/…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13643    Accepted Submission(s): 6011Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster i…
FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge 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 thi…
FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge 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 thi…
题意  输入n个老鼠的体重和速度   从里面找出最长的序列  是的重量递增时速度递减 简单的DP  令d[i]表示以第i个老鼠为所求序列最后一个时序列的长度  对与每一个老鼠i  遍历全部老鼠j  当(w[i] > w[j]) && (s[i] < s[j])时  有d[i]=max(d[i],d[j]+1)  输出路径记下最后一个递归即可了 #include<cstdio> #include<algorithm> using namespace std…