随笔分类 -  动态规划-线性DP

摘要:Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to k 阅读全文
posted @ 2018-08-22 16:51 Roni_i 阅读(151) 评论(0) 推荐(0) 编辑
摘要:有一个只含0和1的长度为n的串,问不含有101的所有串的个数。 ——不存在连续的101、010、111的字符串数量 HDU:https://cn.vjudge.net/problem/HDU-3485 51nod: https://blog.csdn.net/Viscu/article/detail 阅读全文
posted @ 2018-08-16 18:36 Roni_i 阅读(220) 评论(0) 推荐(0) 编辑
摘要:``` include using namespace std; const int MAXN=200005; int dp[MAXN],a[MAXN],n,ans= 100000; int main(){ scanf("%d",&n); for(int i=1;i 阅读全文
posted @ 2018-06-25 06:53 Roni_i 阅读(118) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF987C" 【分析】:先求出每个s【i】后面比s【i】大的c【i】的最小值,然后枚举前两个数c(i),c(j)以及 j 后面 递增且存在最小值 的dp(j) 【代码】: include using namespace std; const int INF = 0x3f3f3f3f; 阅读全文
posted @ 2018-06-01 19:03 Roni_i 阅读(287) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.nowcoder.com/acm/contest/87/B来源:牛客网 好奇的XHRlyb想知道,在每个字符串中Cwbc作为子序列分别出现了多少次。 由于Cwbc可能出现的次数过多,你只需要输出每个答案对2000120420010122取模后的结果。 聪明的你在仔细阅读 阅读全文
posted @ 2018-05-15 01:18 Roni_i 阅读(441) 评论(0) 推荐(0) 编辑
摘要:【分析】: 首先按横坐标递增给所有点排序。 定义状态dp[i][j]表示从点i向n走一条路L1,从点j向n走另一条路L2(如下图,两条路互不相交,并且L1在L2上面),L1 + L2的最小值。程序中用distance(i, j)表示点i到点j的距离。 如何计算dp[i, j]呢? 我们考虑k = m 阅读全文
posted @ 2018-05-09 18:22 Roni_i 阅读(182) 评论(0) 推荐(0) 编辑
摘要:``` Secret agent Maria was sent to Algorithms City to carry out an especially dangerous mission. After several thrilling events we find her in the first station of Algorithms City Metro, examining the... 阅读全文
posted @ 2018-05-08 23:37 Roni_i 阅读(148) 评论(0) 推荐(0) 编辑
摘要:题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。 输入格式 输入数据为 阅读全文
posted @ 2018-05-07 21:08 Roni_i 阅读(165) 评论(0) 推荐(0) 编辑
摘要:题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种。 uim指着墙上的价目表(太低级了没有菜单),说:“随便点”。 题目描述 不过uim由于买了一些辅(e)辅(ro)书,口袋里只剩M元(M using namespace std; define ll l 阅读全文
posted @ 2018-05-07 17:57 Roni_i 阅读(198) 评论(0) 推荐(0) 编辑
摘要:``` 1202 子序列个数 题目来源: 福州大学 OJ 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 子序列的定义:对于一个序列a=a[1],a[2],......a[n]。则非空序列a'=a[p1],a[p2]......a[pm]为a的一个子序 阅读全文
posted @ 2018-05-07 16:32 Roni_i 阅读(242) 评论(0) 推荐(1) 编辑
摘要:``` 链接:https://www.nowcoder.com/acm/contest/116/C 来源:牛客网 题目描述 杨老师认为他的学习能力曲线是一个拱形。勤奋的他根据时间的先后顺序罗列了一个学习清单,共有n个知识点。但是清单中的知识并不是一定要学习的,可以在不改变先后顺序的情况下有选择的进行 阅读全文
posted @ 2018-05-04 18:57 Roni_i 阅读(108) 评论(0) 推荐(0) 编辑
摘要:1101 换零钱 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注 1101 换零钱 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 1101 换零钱 基准时间限制:1 秒 空间限制:131072 KB 分值: 20  阅读全文
posted @ 2018-04-26 16:38 Roni_i 阅读(302) 评论(0) 推荐(0) 编辑
摘要:1086 背包问题 V2 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 1086 背包问题 V2 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 1086 背包问题 V2 基准时间限制:1 秒 空间限制:13107 阅读全文
posted @ 2018-04-25 20:10 Roni_i 阅读(228) 评论(0) 推荐(0) 编辑
摘要:【题目】: 一个M*N的矩阵,找到此矩阵的一个子矩阵,并且这个子矩阵的元素的和是最大的,输出这个最大的值。 例如:3*3的矩阵: -1 3 -1 2 -1 3 -3 1 2 和最大的子矩阵是: 3 -1 -1 3 1 2 Input 第1行:M和N,中间用空格隔开(2 <= M,N <= 500)。 阅读全文
posted @ 2018-04-25 18:47 Roni_i 阅读(227) 评论(0) 推荐(0) 编辑
摘要:1050 循环数组最大子段和 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 1050 循环数组最大子段和 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 1050 循环数组最大子段和 基准时间限制:1 秒 空间限制 阅读全文
posted @ 2018-04-24 22:38 Roni_i 阅读(242) 评论(0) 推荐(0) 编辑
摘要:1006 最长公共子序列Lcs 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1006 最长公共子序列Lcs 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1006 最长公共子序列Lcs 基准时间限制:1 秒 空间限制:13 阅读全文
posted @ 2018-04-23 20:31 Roni_i 阅读(232) 评论(0) 推荐(0) 编辑
摘要:非相邻数最大和 ///*任意选若干个不相邻的数得到的和最大*/ #include<cstdio> #include<cstring> #include<queue> #include<iostream> #define maxn 105 #define maxm 10005 #define INF 阅读全文
posted @ 2018-04-23 18:52 Roni_i 阅读(473) 评论(0) 推荐(0) 编辑
摘要:#include #include #include using namespace std; char str[1005]; int f[1005][1005]; int main(){ scanf("%s",str); int len=strlen(str); for(int i=0;i<len;i++) f[i][i]=1; ... 阅读全文
posted @ 2018-03-25 12:32 Roni_i 阅读(119) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std; const int maxn = 3000 + 10; int n,a[maxn],b[maxn],dp[maxn]; int main() { scanf("%d",&n); memset(dp,0,sizeof(dp)); for(int i = 1;i b[j]) maxn = max(maxn,... 阅读全文
posted @ 2018-03-23 09:58 Roni_i 阅读(207) 评论(0) 推荐(0) 编辑
摘要:#include #define ll long long using namespace std; const int maxn=1010; int c[maxn],w[maxn]; int dp[maxn]; int main(){ int n,v; cin>>n>>v; for(int i=1;i>c[i]; for(int i=1;i>w[i]; ... 阅读全文
posted @ 2018-03-23 09:49 Roni_i 阅读(183) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示