随笔分类 -  算法 动态规划

摘要:01背包 完全背包 322. 零钱兑换 给你一个整数数组 coins ,表示不同面额的硬币;以及一个整数 amount ,表示总金额。 计算并返回可以凑成总金额所需的 最少的硬币个数 。如果没有任何一种硬币组合能组成总金额,返回 -1 。 你可以认为每种硬币的数量是无限的。 示例 1: 输入:coi 阅读全文
posted @ 2021-08-30 20:04 douzujun 阅读(281) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std; const int maxn = 1000 + 20; int n, m, M; int dp[maxn][maxn]; /* 4 3 10000 */ void solve() { cin >> n >> m >> M; dp[0][0] = 1; //dp[i][j] = 存储着 j... 阅读全文
posted @ 2018-03-07 20:20 douzujun 阅读(263) 评论(0) 推荐(0) 编辑
摘要:输入n个数,求出这个序列中最长的上升子序列的长度。 如:4 2 3 1 5;(2 3 5是最长上升子序列,长度为3) 阅读全文
posted @ 2018-03-07 19:30 douzujun 阅读(240) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std; const int maxn = 1000 + 100; int n, m; char s[maxn], t[maxn]; int dp[maxn][maxn]; void solve() { cin >> n >> m; cin >> s >> t; for (int i =... 阅读全文
posted @ 2018-03-07 15:02 douzujun 阅读(153) 评论(0) 推荐(0) 编辑
摘要:记忆化搜索与动态规划 题目:n个重量和价值分别为 wi, vi的物品。从这些物品中挑选出总重量不超过W的物品。求所有挑选方案中价值总和的最大值。 阅读全文
posted @ 2018-03-07 00:32 douzujun 阅读(202) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include using namespace std; int N, M, R; // N个小时, M个时间间隔, R个休息时间 const int maxn = 1000 + 24; struct Cow { int start; int end; int value; C... 阅读全文
posted @ 2017-04-28 23:38 douzujun 阅读(180) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include using namespace std; int T, W; //T 时间内 , W : 来回的次数 const int maxn = 1000 + 20; int apple[maxn + 200]; /* dp[i][j]: 给定时刻i, 转移次数已知为 j :即上一时刻同一棵树... 阅读全文
posted @ 2017-04-28 01:21 douzujun 阅读(141) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include using namespace std; /* 4 5 2 3 1 2 3 4 2 2 */ const int maxn = 100 + 20; const int maxv = 100 + 20; const int INF = 100000000; int w[maxn], v[maxn]; int N, W... 阅读全文
posted @ 2017-04-26 21:20 douzujun 阅读(280) 评论(0) 推荐(0) 编辑

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