POJ3616Milking Time题解动态规划DP

POJ3616 Milking Time (简单DP)——菜鸟的ACM之旅 POJ3616 Milking Time 题目大意 奶牛Bessie非常的勤奋,她想在N时间内产出最多的牛奶。我们的老朋友Farmer John 有M个挤奶的时间段,有可能有重叠。每个时间段由开始时间和结束时间组成,每个时间段Bessie会产出e的奶,Farmer John可以在这些时间段里为Bessie挤奶,需要注意的是,必须要挤够一个完整的时间段。但是我们的Bessie也会劳累,每挤完一次奶,她就要休息R小时,求在N小时内挤出奶的最大量 思路 DP,d[i] 表示在i这个时刻,挤出奶的最大量。时间段表示 阅读详情
Milking Time
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 2159 Accepted: 890

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: N, M, 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 2
1 2 8
10 12 19
3 6 24
7 10 31

Sample Output

43

Source

 
 
状态:
先按结束时间排序
d[i]表示第i个区间和前面的区间组成的最优值
状态转移方程:
d[i]=max(d[j])+w[i].v       (w[i].s>=w[j].e+r)
最终结果是max{d[i]}
刚开始直接写的d[m]一直WA
w[0].e=-r
代码:
国密系列算法简介 众所周知,为了保障商用密码的安全性,国家商用密码管理办公室制定了一系列密码标准,包括SM1(SCB2)、SM2、SM3、SM4、SM7、SM9、祖冲之密码算法(ZUC)那等等。其中SM1、SM4、SM7、祖冲之密码(ZUC)是对称算法;SM2、SM9是非对称算法;SM3是哈希算法。目前,这些算法已广泛应用于各个领域中,期待有一天会有采用国密算法的区块链应用出现。其中SM1、SM7算法不公开,调用该... 阅读详情

相关推荐

保姆级教程:2026版Windows电脑换新,微信QQ聊天记录无损搬家(附路径修改避坑指南)

本文提供2026版Windows电脑换新时微信QQ聊天记录无损迁移的保姆级教程,涵盖最新版微信/QQ的存储路径修改和避坑指南。通过详细步骤和实战技巧,确保数据迁移过程中不丢失任何珍贵对话记录和文件,特别适合需要保留完整聊天记录的用户。

weixin_42629815的博客 2477

动态规划 (区间问题)

1、题目引入: Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her nextN(1 ≤N≤ 1,000,000) hours (conveniently labeled 0..N-1) so that she produces as much milk as possible. Farmer Jo...

weixin_52914088的博客 345

BQ25798双电源输入4节电池升降压充电与最大功率跟踪于光伏板应用

介绍一颗具有窄范围直流电压NVDC、路径管理PPMT、光伏板最大功率跟踪及反向放电OTG升降压充电控制器,带I2C接口能对内部寄存器做控制

linkedin_38804946的博客 1675

Milking Time(dp)

【问题】 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 tha...

qq_45949914的博客 330

Pythia: A Customizable Hardware Prefetching Framework Using Online Reinforcement Learning——“预取”论文解读

参考传送门: 1. Hardware Prefetching笔记 2. 全球百科——缓存预取 3. 百度百科——缓存数据预期技术 目录0. 什么是Hardware Prefetching(本节内容不包括在论文中)1. 简介1.1 关于Hardware Prefetching的一些关键信息1.2 现阶段方法的缺陷1.3 论文团队的目标1.4 核心思想2. 必要的背景知识介绍2.1 强化学习(Reinforcement learning)2.2 为什么说强化学习是一个好的解决思路3. 解决方法与思路3.1 Py

Pinkgranite86的博客 2166

模电实验室:手把手教你调试共射放大电路静态工作点(避免波形失真)

本文详细介绍了共射放大电路静态工作点的调试方法,帮助避免波形失真问题。从实验准备、电路搭建到静态工作点测量,提供了实用的电阻选值策略和常见波形失真解决方案,适合电子相关专业学生和硬件工程师参考学习。

weixin_42531128的博客 375

Milking Time (贪心+dp)

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...

点点滴滴 285

编译CycloneDDS和CycloneDDS-CXX踩过的坑——CMake Error at CMakeLists.txt:227 (find_package):

最近编译CycloneDDS和CycloneDDS-CXX踩了两个坑,花了不少时间。做个简单的记录,免得以后又踩到。注意:CycloneDDS-CXX编译依赖CycloneDDS,因此必须先编译CycloneDDS需要严格按照步骤进行,否则要入坑步骤如下,1先编译CycloneDDS以上步骤完成CycloneDDS的编译和安装,生成的bin include lib等位于install目录下面。

usstmiracle的博客 1900

【题解】Luogu P2889 [USACO07NOV]挤奶的时间Milking Time

Luogu P2889 [USACO07NOV]挤奶的时间Milking Time 题目描述 传送门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 ≤...

C@bMv7GRVt)Q 297

VFIO框架源码分析(二十一)- IOMMUFD 模式下的 DMA 映射机制

在虚拟化 I/O 的世界里,无论上层管理面(如对象模型、设备绑定)如何重构,数据面最核心的任务始终未变——DMA 映射(DMA Mapping)。即如何建立 Guest Physical Address (GPA) 到 Host Physical Address (HPA) 的映射关系,并将其填入 IOMMU 的硬件页表中,使得直通设备能够正确访问虚拟机内存。在 Legacy VFIO (Type1) 时代,这一职责由承担,它通过ioctl 操作 Container。

qq_36071928的博客 1007

【异常】解决 Cursor 报错 Unexpected seqno: 2 != 1. Please try again, or contact support if the issue 的排坑指南

在使用 Cursor 辅助编程时,你是否遇到过 AI 突然中断输出,并在右下角弹出一个红色的 Network Error 弹窗?今天我们就来彻底解析并解决这个网络断连问题。

奶爸的编程之路,也就一周冷个三天 2470

Milking Time POJ - 3616(动态规划DP)

Milking Time POJ - 3616 ...

codeswarrior的博客 401

自建 HTML获取腾讯六宫格点选图片验证码素材,实现刷新批量获取图片方便训练

通过自建 HTML 页面,可以方便地获取腾讯六宫格二维码素材,不仅过程简单,而且可以灵活配置各种参数。希望这篇文章能帮助到需要相关素材的小伙伴。如果你有其他问题或者更好的方法,欢迎留言交流!

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 486

POJ 3616 Milking Time

Milking Time Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5507 Accepted: 2304 Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivi

小寒 427

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

poj 3616 Milking Time

dp题。 /* POJ: 3616 Milking Time */ #include #include #include #include #include #define M 1005 using namespace std; struct Interval { long long start, end; long long eff; bool

stormdpzh的专栏 847

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

POJ - 3616 Milking Time(DP+LIS)

DescriptionBessie 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

00后的博客 206

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

POJ 3616 Milking Time 挤奶问题,带权区间DP

题目链接:POJ 3616 Milking Time Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4837   Accepted: 2034 Description Bessie is such a hard-

一蓑烟雨 6041

动态规划:POJ 3616 Milking Time

动态规划:POJ 3616 Milking Time #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <cstdlib> using namespac...

豆子 140

POJ3616Milking Time

题目链接点击打开链接:poj3616 题目大意: 在一个农场里,在长度为N个时间可以挤奶,但只能挤M次,且每挤一次就要休息t分钟; 接下来给m组数据表示挤奶的时间与奶量求最大挤奶量 本题其实很简单的,一个简单的动态规划,用一个dp表示在第i个时间段挤奶量的最大值,从i+1更新到M 不要忘记排序#include #include #include #include #inc

北门的智慧 3926

POJ 3616 Milking Time 动态规划

http://poj.org/problem?id=3616 题意:一个奶牛在0~N时间段内可被取奶,每次挤奶以后必须休息至少R分钟才能下次继续挤奶。有M次可以挤奶的时间段,每次取奶对应三个值:开始时间、结束时间、效率值,每次挤奶的过程不能中断。求出最大效率值。 解法:首先按照结束时间从小到大排序(按照结束时间排序方便后边的dp);dp[i]表示第i个挤奶时间段后,效率最大值。 转移

ACM_10000h的专栏 990

POJ 3616 Milking Time dp

http://poj.org/problem?id=3616 题意: 一只牛有m个时间段可以挤奶, 每个时间段能挤出v升奶, 每次挤奶后需要rest分钟休息(然而题意是第7分钟挤完奶, 休息两分钟, 第9分钟就能再次挤奶了....毒瘤题意) 思路: 先说比较好的思路, 毒瘤思路一会再敲... ①正常思路: 将所有的时间段按结束时间从小到大排序, dp[i]表示第i个时间段结束时,得到的...

swqeaaa的博客 237

POJ 3616 Milking Time (DP)

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

pxlsdz的博客 1742

Milking Time POJ【3616】

题目链接 大概题意 有一个奶牛在不同的时间产奶量是不同的,现在有m个时间段,每个时间段【l,r】里可以产奶v斤奶,每次产奶后都要有r个时间的休息时间,问你在n个时间里,这个奶牛可以产奶的最大量是多少 解题思路 虽然一眼看过去就知道是个dp可是一脸懵逼的推了一会没推出来。。。 dp【i】是第i个时间段里可以产的最大奶量,只需要控制前面的结束的时间大会小于后面的开始时间就好 #include<s...

qq_41925919的博客 231

[POJ 3616 DP] Milking Time

dp[i] 表示到达time_i时获得的最大价值,dp[i] = max(dp[i - 1],dp[end_timej - start_timej] + valuej),因为还有个休息时间,每次挤奶会多占用rest_time,如果end_timej + rest_time > n,令其取n则可,这样原本的end_timej ~ n 这一段也不会用于挤其他奶牛。 #include<iostream> #include<vector> #define debug(x) cout&l

我们仍未知道那天所看见的花的名字。 167

Milking Time POJ - 3616

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 l

qcccc_的博客 3482

poj 3616 Milking Time (基础dp)

题目链接http://poj.org/problem?id=3616 题意:在一个农场里,在长度为N个时间可以挤奶,但只能挤M次,且每挤一次就要休息t分钟; 接下来给m组数据表示挤奶的时间与奶量求最大挤奶量 看似很复杂其实就是求大递增序列即可,先将M次挤奶进行排序按照end从小到大排序然后判断s[i].sta-r>=s[j].end时可以加上。 #include &...

awow80285的博客 113
上一篇: POJ3211Washing Clothes题解动态规划DP
下一篇: POJ3260The Fewest Coins题解动态规划DP
power721
博客等级 码龄18年 176粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值