Milking Time---poj3616】的更多相关文章

#include <iostream> #include <cstdio> #include <algorithm> using namespace std; struct cow { int start; int endd; int price; }; bool cmp(cow a,cow b) { return a.start<b.start; } int main() { int n,m,r; cow a[1005]; cin>>n>>…
https://vjudge.net/problem/POJ-3616 猛刷简单dp的第一天第二题. 这道题乍一看跟背包很像,不同的在于它是一个区间,背包是定点,试了很久想往背包上套,都没成功. 这题的思路感觉有点陌生,又有点类似于求最长不降子序列的题. dp[i]为到第i个区间为止(该区间肯定有i)的最大挤奶量,最后从m个里面取最大. #include<iostream> #include<cstdio> #include<queue> #include<cst…
题目链接:http://poj.org/problem?id=3616 Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10819   Accepted: 4556 Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she dec…
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. Fa…
Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5682   Accepted: 2372 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 ≤…
http://poj.org/problem?id=3616 bessie是一头工作很努力的奶牛,她很关心自己的产奶量,所以在她安排接下来的n个小时以尽可能提高自己的产奶量. 现在有m个产奶时间,每个都有一个开始时间和结束时间和这个时间内的产奶量,任意一个时间段产奶之后,bessie都要休息r个时间,问如果安排产奶才能得到最大值. 注意这里m个时间其实都安排在n时间内,所以n其实是没用的. 设dp[i]是前i个时间内最多的产奶量    dp[i]=max(dp[i-1],dp[p[i]]+w[i…
注意0,1,.....,N是时间点,i~i+1是时间段 然后就是思路:dp[i]代表到时间点 i 获得的最大价值, 1:dp[i]=max(dp[i],dp[s-r]+e),表示有以s为开头,i为结尾的工作时间,效率是e(保证前面有工作) 2:dp[i]=max(dp[i],e),表示前面没有工作 3:dp[i]=max(dp[i],dp[i-1]),保存到时间点i的最大价值 代码如下 #include<cstdio> #include<cstring> #include<a…
思路: dp. 实现: #include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; ll n,m,r; struct node { ll start; ll end; ll p; }; node a[]; ll dp[]; bool cmp(const node & a,const node & b) { if(…
Milking Time 直接翻译了 Descriptions 贝茜是一个勤劳的牛.事实上,她如此​​专注于最大化她的生产力,于是她决定安排下一个N(1≤N≤1,000,000)小时(方便地标记为0..N-1),以便她生产尽可能多的牛奶. 农民约翰有一个M(1≤M≤1,000)可能重叠的间隔列表,他可以在那里进行挤奶.每个区间我有一个起始小时(0≤starting_houri≤N),一个结束小时(starting_houri <ending_houri≤N),以及相应的效率(1≤efficien…
Secret Milking Machine Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11865   Accepted: 3445 Description Farmer John is constructing a new milking machine and wishes to keep it secret as long as possible. He has hidden in it deep within…
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends a…
                                                        Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7153   Accepted: 3047 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid tha…
Optimal Milking Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 13968 Accepted: 5044 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows.…
                                         Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 16461   Accepted: 5911 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow past…
P1204 [USACO1.2]挤牛奶Milking Cows 474通过 1.4K提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 请各位帮忙看下程序 错误 谢… 求大神扫一眼,模拟算法 求帮看看哪儿错 帮忙看看为什么不过 帮我看看哪里错了,挤牛奶,… 帮我看看哪里错了 题目描述 三个农民每天清晨5点起床,然后去牛棚给3头牛挤奶.第一个农民在300秒(从5点开始计时)给他的牛挤奶,一直到1000秒.第二个农民在700秒开始,在 1200秒结束.第三个农民…
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends at time 1200.…
Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4738   Accepted: 1978 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75…
                                                                                             Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8048   Accepted: 3388 Description Bessie is such a hard-working cow. In fact, she i…
A. Milking cows time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n…
Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75) columns. As we all know, Farmer John is quite the expert on cow behavior, and is currently wri…
1642: [Usaco2007 Nov]Milking Time 挤奶时间 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 525  Solved: 300[Submit][Status] Description 贝茜是一只非常努力工作的奶牛,她总是专注于提高自己的产量.为了产更多的奶,她预计好了接下来的N (1 ≤ N ≤ 1,000,000)个小时,标记为0..N-1. Farmer John 计划好了 M (1 ≤ M ≤ 1,000) 个可以…
Description FJ has moved his K ( <= K <= ) milking machines <= C <= ) cows. A ..K; the cow locations are named by ID numbers K+..K+C. Each milking point can <= M <= ) cows each day. Write a program to find an assignment for each cow to s…
Description Bessie ≤ N ≤ ,,) hours (conveniently labeled ..N-) so that she produces as much milk as possible. Farmer John has a list of M ( ≤ M ≤ ,) possibly overlapping intervals ≤ starting_houri ≤ N), an ending hour (starting_houri < ending_houri ≤…
水dp 先按开始时间排序 , 然后dp. dp( i ) 表示前 i 个时间段选第 i 个时间段的最优答案 , 则 dp( i ) = max( dp( j ) ) + w_i ( 0 < j < i ) , answer = max( dp( i ) ) ( 1 <= i <= m ) ------------------------------------------------------------------------------------------- #inclu…
Secret Milking Machine Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9658   Accepted: 2859 Description Farmer John is constructing a new milking machine and wishes to keep it secret as long as possible. He has hidden in it deep within…
POJ  2112 Optimal Milking (二分+最短路径+网络流) Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 10176   Accepted: 3698 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastu…
求使所有牛都可以被挤牛奶的条件下牛走的最长距离. Floyd求出两两节点之间的最短路,然后二分距离. 构图: 将每一个milking machine与源点连接,边权为最大值m,每个cow与汇点连接,边权为1,然后根据二分的距离x,将g[i][j] < x的milking machine节点i与cow节点j连接,边权为1,其他的赋值为零. 最大流的结果是可以被挤奶的cow数量,判断是否等于总的cow总量即可. #include <iostream> #include <cstring…
解题报告 农场有k个挤奶机和c头牛,每头牛到每一台挤奶机距离不一样,每台挤奶机每天最多挤m头牛的奶. 寻找一个方案,安排每头牛到某一挤奶机挤奶,使得c头牛须要走的全部路程中的最大路程的最小值. 要使每一头牛都去挤奶,那么建完模型就要推断是否满流. 因为是多源多点的网络,如果源点0,汇点n+1(n=k+c) 源点到每一头牛的容量为1,每一台机器到汇点的容量为m;用flody求出随意一头牛到随意一台机器的最短路; 对于取最大距离的最小值能够用二分来找. #include <iostream> #i…
Optimal Milking 题目: 有K个机器.C仅仅牛.要求求出最全部牛到各个产奶机的最短距离.给出一个C+K的矩阵,表示各种标号间的距离. 而每一个地方最多有M仅仅牛. 算法分析: 二分+最短路+网络流 想法难以想到.我是看解题报告的思路. 然后.自己上了手.開始wrong 了3次.后来各种该.无意的一个更改就AC了.无语勒. ... wrong 在了,网络流建图的时候仅仅能是机器和奶牛之间的距离关系.而奶牛跟奶牛或者机器跟机器不要建边.当时脑残了.!.! #include <iostr…
1642: [Usaco2007 Nov]Milking Time 挤奶时间 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 590  Solved: 337 [Submit][Status][id=1642" style="color:blue; text-decoration:none">Discuss] Description 贝茜是一仅仅很努力工作的奶牛,她总是专注于提高自己的产量.为了产很多其它的奶,她估计好了接下…