思路:

dp。

实现:

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5. typedef long long ll;
  6. ll n,m,r;
  7. struct node
  8. {
  9. ll start;
  10. ll end;
  11. ll p;
  12. };
  13. node a[];
  14. ll dp[];
  15. bool cmp(const node & a,const node & b)
  16. {
  17. if(a.start != b.start)
  18. {
  19. return a.start < b.start;
  20. }
  21. return a.end < b.end;
  22. }
  23. ll solve()
  24. {
  25. for(int i = ;i < m;i ++)
  26. {
  27. dp[i] = a[i].p;
  28. for(int j = ;j < i;j ++)
  29. {
  30. if(a[j].end <= a[i].start)
  31. dp[i] = max(dp[i], dp[j] + a[i].p);
  32. }
  33. }
  34. ll maxn = ;
  35. for(int i = ;i < m;i ++)
  36. maxn = max(maxn, dp[i]);
  37. return maxn;
  38. }
  39. int main()
  40. {
  41. cin >> n >> m >> r;
  42. for(int i = ;i < m;i ++)
  43. {
  44. scanf("%lld%lld%lld",&a[i].start,&a[i].end,&a[i].p);
  45. a[i].end += r;
  46. }
  47. sort(a, a + m,cmp);
  48. cout << solve() << endl;
  49. return ;
  50. }

poj3616 Milking Time的更多相关文章

  1. 动态规划 POJ3616 Milking Time

    #include <iostream> #include <cstdio> #include <algorithm> using namespace std; st ...

  2. poj3616 Milking Time(状态转移方程,类似LIS)

    https://vjudge.net/problem/POJ-3616 猛刷简单dp的第一天第二题. 这道题乍一看跟背包很像,不同的在于它是一个区间,背包是定点,试了很久想往背包上套,都没成功. 这题 ...

  3. POJ3616 Milking Time —— DP

    题目链接:http://poj.org/problem?id=3616 Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  4. POJ3616 Milking Time【dp】

    Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her producti ...

  5. poj-3616 Milking Time (区间dp)

    http://poj.org/problem?id=3616 bessie是一头工作很努力的奶牛,她很关心自己的产奶量,所以在她安排接下来的n个小时以尽可能提高自己的产奶量. 现在有m个产奶时间,每个 ...

  6. POJ3616 Milking Time 简单DP

    注意0,1,.....,N是时间点,i~i+1是时间段 然后就是思路:dp[i]代表到时间点 i 获得的最大价值, 1:dp[i]=max(dp[i],dp[s-r]+e),表示有以s为开头,i为结尾 ...

  7. 《挑战程序设计竞赛》2.3 动态规划-基础 POJ3176 2229 2385 3616 3280

    POJ3176 Cow Bowling 题意 输入一个n层的三角形,第i层有i个数,求从第1层到第n层的所有路线中,权值之和最大的路线. 规定:第i层的某个数只能连线走到第i+1层中与它位置相邻的两个 ...

  8. 「kuangbin带你飞」专题十二 基础DP

    layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathj ...

  9. POJ3616:Milking Time

    Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5682   Accepted: 2372 Desc ...

随机推荐

  1. Hadoop MapReduce两种架构 以及 YARN

    一.MRv1 Master - Slave 模式 存在JobTracker单点失败的问题,在YARN得到了解决. 主要包含4部分:JobTracker,TaskTracker,Task,Client ...

  2. css3某些特性

    在下列情况下,建议使用opacity属性而不是rgba()函数 1.实现多种颜色(元素)的半透明效果.使用opacity属性,不仅背景颜色,就连文本颜色.边框颜色都会变透明. 2.在不知道颜色的情况下 ...

  3. html5--6-67 阶段练习8-弹性三列布局

    html5--6-67 阶段练习8-弹性三列布局 学习要点 运用弹性盒子模型完成一个三列布局,加深对学过知识点的综合应用能力. 了解用百分比设置元素高度的方法. @charset="UTF- ...

  4. bzoj2660最多的方案——数位DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2660 首先,多种方案的出现是因为一个较大的斐波那契数可以变成两个较小的: 用一个01串来表示 ...

  5. 廖雪峰python3练习题一

    数据类型和变量 题目: 答案: print(123) print(456.789) print('\'Hello,world\'') print('\'Hello,\\\'Adam\\\'\'') p ...

  6. shell脚本只提供整数算术运算(三种方式)—((表达式))、let "表达式"、value=`expr 表达式右边` (转载)

    转自:http://blog.163.com/xychenbaihu@yeah/blog/static/132229655201131055455754/ 数值运算: 在bash中只提供了整数运算,一 ...

  7. .NET Core 3.0之深入源码理解Configuration(二)

      文件型配置基本内容 上一篇文章讨论了Configuration的几个核心对象,本文继续讨论Configuration中关于文件型配置的相关内容.相比较而言,文件型配置的使用场景更加广泛,用户自定义 ...

  8. Node学习图文教程之express重写留言本案例

    写在前面 小伙伴们大家好,我是你们的pubdreamcc,接着前面的学习,这篇博文出至于我的GitHub仓库:Node学习教程资料,如果你觉得对你有帮助,欢迎star,你们的点赞是我持续更新的动力,谢 ...

  9. (水题)洛谷 - P1579 - 哥德巴赫猜想(升级版)

    https://www.luogu.org/problemnew/show/P1579 先预处理出素数看看有多少个,大概才2500个不到(事实上素数的个数大约是 $\frac{n}{ln(n)}$ ) ...

  10. poj2421【MST-prim+Kruskal】

    水过~~~~打好基础/~~ ------prim #include <iostream> #include <stdio.h> #include <string.h> ...