随笔分类 - -------动态规划-------
摘要:problemsolutioncodes//多少个最长不上升子序列可以覆盖这个数列,其实是等效于最长上升子序列的长度#include#includeusing namespace std;int n, h[50], k[50], ans1, ans2 = 1;int ...
阅读全文
摘要:problemsolutioncodes#includeusing namespace std;int n, m, a[355], b[5], dp[40][40][40][40];int main(){ cin>>n>>m; for(int i = 0;...
阅读全文
摘要:problem在一个矩阵内找出两条从(1,1)到(m,n)的路径(一条从1,1 到 m,n 一条 从m, n到1,1),并且路径之上的权值之和最大。solution状态:f[i][j][k][l],当一张纸条传到i,j 另一张传到k,l时路径上权值的最大值;codes...
阅读全文
摘要:problemsolutioncodes//每行独立区间DP, 贪心反例->某行像这样,4 1 1 1 1 1 233 3 3//2^80数据, 所以记得高精.#include#include#include#include#includeusing namespac...
阅读全文
摘要:problem给定 n 颗环形串起来的珍珠,每个珍珠有头标记 hi 和尾标记 ti,按照任意顺序合并相邻珍珠 u, v,会带来 hu ∗ tu ∗ tv 的收益,并且会结合成新的珍珠 w,其中 hw = hu, tw = tv。保证相邻珍珠同侧标记相同。求最大收益。 ...
阅读全文
摘要:problemsolutioncodes#includeusing namespace std;int h[110],f[110],f2[110], ans;int main(){ int n; cin>>n; for(int i = 1; i >h[i]...
阅读全文
摘要:problem占坑待填solution占坑待填???codes//交前%一下, 送你80分#include#includeusing namespace std;const int maxn = 30000010;#define mod 23301int l, s, ...
阅读全文
摘要:题面完全背包题解#includeusing namespace std;const int maxn = 100010;int n, m, c[maxn], w[maxn], f[maxn];int main(){ cin>>m>>n; for(int i...
阅读全文
摘要:题面01背包 注意输入线体积再物品个数题解//f[i][j]:当前在选第i个物品,剩余体积为j时能获得的最大价值。#includeusing namespace std;const int maxn = 1010;int n, m, w[maxn], v[maxn],...
阅读全文
摘要:题面以一个长为n的数列,求连续子段的最大值。思路1直接枚举O(n^3)TLE稳稳的#includeusing namespace std;int n, a[50050], ans;int main(){ cin>>n; for(int i = 1; i >...
阅读全文
摘要://f[i]:长为i的LIS末位的最小值#include#include#includeusing namespace std;int f[1000010];int main(){ memset(f,0x3f,sizeof(f)); int n; cin...
阅读全文
摘要:提交:http://codevs.cn/problem/1048/递推//f[i]:到i为止的LIS的长度。//f[i]=max{1,f[j]+1|j#includeusing namespace std;int n, a[510], f[510], ans;int ...
阅读全文
摘要:0x01题面给定一个长为n的序列,求它的最长上升子序列。 n<103" role="presentation" style="position: relative;">nf[i-1]才成立。 转移: (e)如何得到长为i的LIS的末位最小值{1.找到后面第一个比...
阅读全文