
dp
threeh20
暑假有半个月整个人像死了一样,所以更加明白生命的可贵
展开
-
hdu 1231 最大连续子序列
最大连续子序列 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 8 Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size:原创 2017-07-15 21:06:10 · 190 阅读 · 0 评论 -
HihoCoder 1636 Pangu and Stones(区间dp)
https://hihocoder.com/problemset/problem/1636 dp[i][j][k]表示将i到j范围内的石头合并最终成k堆的最优解。 所以这么看来最终的答案就是dp[1][n][1] 与正常的石头堆合并不一样的是那个可以随便合并,所以我们可以在i到j中找一个中间点来更新ij的最优, 但是这道题不可以,因为至少也需要l堆石头合并,那怎么办呢 方法就...原创 2018-11-01 22:04:02 · 212 阅读 · 0 评论 -
hdu 5965 扫雷(动态规划)
http://acm.hdu.edu.cn/showproblem.php?pid=5965 枚举每一列的雷的数量,只有012三种情况,1的情况有2种方式 那么我们就可以根据前2列的情况来推出第三列雷的数量的情况 #include<bits/stdc++.h> using namespace std; #define ll long long int const i...原创 2018-10-21 12:37:00 · 465 阅读 · 0 评论 -
hdu 1429 胜利大逃亡(续)(状压dp+bfs)
http://acm.hdu.edu.cn/showproblem.php?pid=1429 因为图中需要记录钥匙的拥有情况,所以需要用状态压缩的思想,来用一个数字表示对应二进制位数上的钥匙有无情况 再结合bfs即可 #include<bits/stdc++.h> using namespace std; struct node{ int x; ...原创 2018-08-09 10:53:12 · 193 阅读 · 0 评论 -
poj3635 Full Tank?(dp+bfs/dij)
http://poj.org/problem?id=3635给一张图,n个点,m条无向边,每个点都有自己的油价,每条路都需要消耗相应体积的油。q次询问,问一个小车,给定起点终点以及油箱容量,问到达终点的最小花费。懵了!看了下题解,是dp加bfs或者是dijdp[i][j]是指到达i点剩j体积的油量的最小花费。因为油最多只有100,所以可以这么做。对于每一个状态,我们可以有2个选择,1 在这个点加1...原创 2018-07-14 10:31:13 · 402 阅读 · 0 评论 -
Let's Go Rolling! CodeForces - 38E
http://codeforces.com/problemset/problem/38/E数轴上有一些点,开始会向左边滚动,最终花费等于每个点滚过的距离,每个点还可以花费相应的数值来插上一个挡板,后面的点滚到该点则会停下,求最终的最小花费。dp。先按位置前后排序dp[i][j]代表第i个点在第j个点停下了,当然有j<=i;对于当前这个点,如果在自己这个点停下,则去前面的点在前一个点停下和在自...原创 2018-04-07 19:34:59 · 273 阅读 · 0 评论 -
poj 1952 BUY LOW, BUY LOWER
http://poj.org/problem?id=1952 #include #include using namespace std; const int N=5005; int dp[N],a[N],count[N]; int main() { bool mark; int n,i,j,k,max;原创 2017-11-11 20:53:31 · 302 阅读 · 0 评论 -
CodeForces 332B Maximum Absurdity
http://codeforces.com/problemset/problem/332/B #include using namespace std; int a[222222]; long long int b[222222]; long long int c[222222]; long long int w[22222原创 2017-10-29 17:20:23 · 317 阅读 · 0 评论 -
zufeoj 2231四正要出国
http://172.21.2.10/JudgeOnline/problem.php?id=2231 #include #include using namespace std; int a[111111]; int pre[111111]; int main(){ int n; while(scanf("%原创 2017-10-29 17:30:38 · 650 阅读 · 0 评论 -
zufeoj 2233 免费的pizza
http://172.21.2.10/JudgeOnline/problem.php?cid=1468&pid=4 #include #include #include #include using namespace std; char a[111111]; int main(){ while(scanf("%s",&a)!=EOF){原创 2017-10-29 17:33:04 · 330 阅读 · 0 评论 -
codeforces 835c Star sky
C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set in the s原创 2017-08-02 20:45:58 · 296 阅读 · 0 评论 -
poj3406 Ant Counting
Ant Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6012 Accepted: 2240 Description Bessie was poking around the ant hill one day watching the ant原创 2017-08-09 19:43:33 · 248 阅读 · 0 评论 -
hdu 1978 How many ways
How many ways Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 50 Accepted Submission(s) : 32 Font: Times New Roman | Verdana | Georgia Fo原创 2017-07-15 20:34:08 · 196 阅读 · 0 评论 -
HDU 6249 Alice’s Stamps(dp)
http://acm.hdu.edu.cn/showproblem.php?pid=6249 dp[i][j]表示在1-i的邮票内买j套所得到最多的邮票数 ri[i]表示第i种邮票所在的套装中最右边的邮票id #include<bits/stdc++.h> using namespace std; int dp[2222][2222]; int ri[2222]; ...原创 2018-11-01 22:13:00 · 174 阅读 · 0 评论