博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Milking Time
阅读量:6364 次
发布时间:2019-06-23

本文共 1972 字,大约阅读时间需要 6 分钟。

Description

Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,000) hours (conveniently labeled 0..N-1) so that she produces as much milk as possible.

Farmer John has a list of M (1 ≤ M ≤ 1,000) possibly overlapping intervals in which he is available for milking. Each interval i has a starting hour (0 ≤ starting_houri ≤ N), an ending hour (starting_houri < ending_houri ≤ N), and a corresponding efficiency (1 ≤ efficiencyi ≤ 1,000,000) which indicates how many gallons of milk that he can get out of Bessie in that interval. Farmer John starts and stops milking at the beginning of the starting hour and ending hour, respectively. When being milked, Bessie must be milked through an entire interval.

Even Bessie has her limitations, though. After being milked during any interval, she must rest R (1 ≤ R ≤ N) hours before she can start milking again. Given Farmer Johns list of intervals, determine the maximum amount of milk that Bessie can produce in the N hours.

Input

* Line 1: Three space-separated integers: NM, and R

* Lines 2..M+1: Line i+1 describes FJ's ith milking interval withthree space-separated integers: starting_houri , ending_houri , and efficiencyi

Output

* Line 1: The maximum number of gallons of milk that Bessie can product in the N hours

Sample Input

12 4 21 2 810 12 193 6 247 10 31

Sample Output

43
/*题意:奶牛在0~n的区间内产奶,农场主有m个时间段可以挤奶并且给出第i个时间段的挤奶产量,农场主每次挤完奶之后必须休息时间r之后    才能工作,问农场主最多可以挤多少奶初步思路:贪心#错误:贪心解决不了问题还是得动态规划,dp[i]表示第i个时间段能获得的最大奶量,dp[i]=max(dp[i],dp[j]+fr[i].val);    注意这个dp[j]的结束时间不能和dp[i]的开始时间冲突*/#include 
#include
#include
#include
using namespace std;struct node{ int l,r,val; bool operator < (const node & other) const{ if(l==other.l) return r

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6581972.html

你可能感兴趣的文章
Spring3 MVC中使用Swagger生成API文档
查看>>
FastCGI PHP on Windows Server 2003
查看>>
LimeSDR Getting Started Quickly | LimeSDR上手指南
查看>>
JSP标签JSTL的使用(1)--表达式操作
查看>>
SAP顾问的人脉比技术更为重要
查看>>
FI/CO PA考试试卷
查看>>
汽车介质应用非常严苛?没关系,新技术带来的高精度传感器十分适应!
查看>>
天合光能 - 用计算捕捉“光的能量”
查看>>
使用sysbench压力测试MySQL(一)(r11笔记第3天)
查看>>
css知多少(11)——position
查看>>
【Spring】定时任务详解实例-@Scheduled
查看>>
先有的资源,能看的速度看,不能看的,抽时间看。说不定那天就真的打不开了(转)...
查看>>
[20161028]rman与filesperset=1.txt
查看>>
哪些领域适合开发微信小程序
查看>>
谁说数据库防火墙风险大?可能你还不知道应用关联防护
查看>>
ASP.NET Core应用针对静态文件请求的处理[2]: 条件请求与区间请求
查看>>
数据的阴暗面:什么是暗数据?为什么暗数据很重要?
查看>>
怎样做一个企业?尤其是在这个互联网时代
查看>>
防患于未然,网络安全由全而智
查看>>
DVNA:Node.js打造的开源攻防平台
查看>>