![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心问题
贪心问题
懒狗的救赎
HUMBLE.
展开
-
马戏团【动态规划】
#include <iostream> #include <cstring> using namespace std; int dp[21][21]; int fun(int n,int k){ //k表示余额份数 if(dp[n][k]>=0) return dp[n][k]; int ans; if(k<0||k>n) //当余额小于0,或者余额超过n份 ans = 0; else if(n==原创 2021-03-23 19:23:22 · 181 阅读 · 0 评论 -
KY179 搬水果
思路: 哈夫曼编码 代码: #include <iostream> #include <cstring> #include <algorithm> #include <map> using namespace std; int main(){ int n,a[10005]; map<int,bool> MAP; while(cin>>n){ if(n==0) break;原创 2021-03-22 21:19:06 · 107 阅读 · 0 评论 -
Aggressive cows
题目地址:点击 #include <iostream> #include <cstring> #include <algorithm> using namespace std; int stall[100005]; bool judge(int n,int c,int distance){ //distance是当前最小距离,函数判断此距离是否满足放下所有牛 int x=stall[0]; //当前放牛的位置 int num=1;原创 2021-03-06 00:02:02 · 93 阅读 · 0 评论 -
3104 Drying【贪心 二分】
题目地址:点击原创 2021-03-05 20:14:17 · 103 阅读 · 0 评论 -
1328 Radar Installation【区间贪心问题】
题目地址:点击原创 2021-03-05 20:11:40 · 54 阅读 · 0 评论 -
2037 今年暑假不AC【区间贪心问题】
题目地址:点击 思路: 每次选择结束时间最早的,意味着会有更多的时间进行选择。 代码: #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef struct{ int begin; int end; }program; bool cmp(program a,program b){ return a.end<b.end原创 2021-03-05 19:46:32 · 81 阅读 · 0 评论 -
1045. 箱子打包
题目地址:点击 代码: #include <iostream> #include <cstring> #include <algorithm> using namespace std; int main(){ int n; double l; cin>>n>>l; double box[n]; for(int i=0;i<n;i++) cin>>box[i]; so原创 2021-03-05 15:23:02 · 71 阅读 · 0 评论