poj 3034 动态规划】的更多相关文章

思路:这是一道坑爹的动态规划,思路很容易想到,就是细节. 用dp[t][i][j],表示在第t时间,锤子停在(i,j)位置能获得的最大数量.那么只要找到一个点转移到(i,j)收益最大即可. #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #includ…
17-单调递增最长子序列 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:21 submit:49 题目描述: 求一个字符串的最长递增子序列的长度 如:dabdbf最长递增子序列就是abdf,长度为4 输入描述: 第一行一个整数0<n<20,表示有n个字符串要处理 随后的n行,每行有一个字符串,该字符串的长度不会超过10000 输出描述: 输出字符串的最长递增子序列的长度 样例输入: 复制 3 aaa ababc abklmncdefg 样例输…
思路:简单动态规划 #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring> #include<iostream> #include<algorit…
用贪心简单证明之后就是一个从两头取的动态规划 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e3+9; int a[maxn],b[maxn]; int dp[maxn][maxn]; bool cmp(int a,int b) { return a>b; } int m…
Description While visiting a traveling fun fair you suddenly have an urge to break the high score in the Whac-a-Mole game. The goal of the Whac-a-Mole game is to… well… whack moles. With a hammer. To make the job easier you have first consulted the f…
Whac-a-Mole Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3070 Accepted: 922 Description While visiting a traveling fun fair you suddenly have an urge to break the high score in the Whac-a-Mole game. The goal of the Whac-a-Mole game is t…
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 42914 Accepted: 18914 Description A numeric sequence of ai is ordered if a1 < a2 < - < aN. Let the subsequence of the given numeric sequence (a1, a2, -, aN) be…
题目链接 理解了题意之后,这个题感觉状态转移还是挺好想的,实现起来确实有点繁琐,代码能力还有待加强,经过很长时间才发现bug.注意坐标可能是负的. #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> using namespace std; ][][]; ][][]; int n,ans,d; int gcd(…
题目链接 题意 : 在一个二维直角坐标系中,有n×n个洞,每个洞的坐标为(x,y), 0 ≤ x, y < n,给你一把锤子可以打到地鼠,最开始的时候,你可以把锤子放在任何地方,如果你上一秒在(x1,y1),那下一秒直线移动到的整数点(x2,y2)与这个点的距离小于等于d,并且当锤子移动(x2,y2)这个点时,所有在两点的直线上的整点数都可以打到.例如(0,0)移动到(0,3).如果(0,1),(0,2)有老鼠出现就会被打到.求能够打的最多老鼠. 思路 : Dp[i][j][k]代表点(i,j)…
思路:每次枚举每个工人的右边界j,维护最优的左边界k.那么dp[j]=max(dp[j],dp[k]+(j-k)*w[i].p): 对于每个工人的初值k=w[i].s-1; 令x=j-w[i].l,如果(k-x)*w[i].p>dp[k]-dp[x],则k=x. #include<set> #include<map> #include<cmath> #include<queue> #include<cstdio> #include<v…