
dp
fl_334
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
洛谷p1388算式(dp)
#includeusing namespace std;int x[100][100];int main(){ int n,r; cin>>n>>r; int a[1000]; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=n;i++) for (int j=i;j<=n;j++){ x[i][j]=x[i][j-1原创 2016-11-12 20:58:06 · 422 阅读 · 0 评论 -
[luogu1004]方格取数(dp,亚瑟)
某人从图中的左上角的A出发,可以向下行走,也可以向右行走,直到达右下角的B点。在走过的路上,他可以取走方格中的数(取走后的方格中将变为数字0)。 此人从A点到B点共走了两次,试找出两条这样的路径,使得取得的数字和为最大。INPUT 8 2 3 13 2 6 6 3 5 7 4 4 14 5 2 21 5 6 4 6 3 15 7 2 14 0 0 0 OUTPUT 67#in原创 2017-08-17 18:14:10 · 311 阅读 · 0 评论 -
最大子矩阵和(n^2*m,dp,前缀和)
INPUT: 5 4 -1 -2 -3 -4 -3 -2 2 4 -3 -4 3 5 4 -5 3 6 -3 -2 -1 0 OUTPUT 23前缀和+dp优化#include<iostream>using namespace std;const int maxn=600;int n,m;long long f[maxn];long long s[maxn][maxn];in原创 2017-08-03 13:33:14 · 581 阅读 · 0 评论 -
[UVA1626]Brackets sequence(dp)
样例: 1([(]#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int INF=1<<30;const int maxn=110;int f[maxn][maxn];int pd(char x,char y){ if (x=='('&&y==')'||x=='['&原创 2017-06-30 22:19:47 · 256 阅读 · 0 评论 -
[UVA10003] 切木棍(dp)
**样例: 100 3 25 50 75 10 4 4 5 7 8 0 **#include<iostream>using namespace std;const int maxn=1010;int f[maxn][maxn];int s[maxn];int main(){ int l,n; while (true){ cin>>l;原创 2017-06-30 21:41:53 · 388 阅读 · 0 评论 -
luogu P3143 钻石收藏(dp)
题目大意收集了N颗钻石(N她不会把两个大小相差K以上的钻石同时放在一个陈列架上(差值可等于K)现在给出K,请你帮Bessie确定她最多一共可以放多少颗钻石在这两个陈列架上。#include#includeusing namespace std;const int maxn=200100;int a[maxn],l[maxn],r[maxn];int main()原创 2017-03-27 19:58:54 · 460 阅读 · 0 评论 -
luoguP2439教室利用(贪心,排序,dp)
题目大意:读入所有演讲的起始和终止时间;计算最大的可能演讲总时间我们假设在某一演讲结束的瞬间我们就可以立即开始另一个演讲。#include#includeusing namespace std;struct data{ int x; int y;}a[5010];int f[5010]={0};int cmp(data a,data b){ if (a.x原创 2017-03-04 20:49:17 · 453 阅读 · 0 评论 -
RQNOJ 172 圣诞树(dp)
题目:这棵树有n层,每层有一件礼物,每件礼物都有一个价值,有的礼物还有一些连结线,与下层的礼物相连,领取礼物的规则如下:任选一件礼物,它的下面如果有连结线,则可以继续取它连结的礼物,以此类推,直至取到没有连结线的礼物才结束,你如果是第一个去取,怎样取才能获得最大的价值呢?var //Pascal不是重点a,b:array[0..100]of longint;map:ar转载 2017-02-18 13:56:28 · 715 阅读 · 0 评论 -
洛谷p2800又上锁妖塔
题目大意:一个塔,有n层,高度不同,小A可以选择跳,用一次可以让他向上跳一层或两层,但是每次跳后小A必须爬过至少一层才能再次跳跃,或者爬,每爬一层要消耗当前楼层高度的时间,求最短时间。#include#includeusing namespace std;int a[1001000],p[1001000],t[1001000];int main(){ int n; cin>>n;原创 2017-02-18 13:27:59 · 372 阅读 · 0 评论 -
洛谷p2015苹果二叉树
有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的结点)这棵树共有N个结点(叶子点或者树枝分叉点),编号为1-N,树根编号一定是1。我们用一根树枝两端连接的结点的编号来描述一根树枝的位置。下面是一颗有4个树枝的树2 5 \ / 3 4 \ / 1 现在这颗树枝条太多了,需要剪枝。但是一些树枝上长有苹果。给定需要保留的树枝数量,求出最多能留住多少苹果原创 2016-11-12 21:04:31 · 372 阅读 · 0 评论 -
包含第k元素LIS(dp)
输入样例 8 6 65 158 170 299 300 155 207 389 输出样例 4 #include<iostream> using namespace std; const int maxn=1010; int n,k; int f[maxn],g[maxn],a[maxn]; int main(){ cin>>n>>k; for (int原创 2017-08-03 18:26:47 · 349 阅读 · 0 评论