【动态规划】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 ha…
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <cstdlib> using namespace std; int N, M, R; // N个小时, M个时间间隔, R个休息时间 + ; struct Cow { int start; int end; int value; Cow(, , ) : start(s),…
Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7265   Accepted: 3043 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 ≤…
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…
传送门: http://poj.org/problem?id=3616 Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13406   Accepted: 5655 Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she dec…
题目链接:http://poj.org/problem?id=3616 有头牛产奶n小时(n<=1000000),但必须在m个时间段内取奶,给定每个时间段的起始时间和结束时间以及取奶质量 且两次取奶之间须间隔r-1个小时,求最大取奶质量 也就是说r = 2时 3分结束取奶,至少在5分才能取. 按照时间排序,dp[i]表示i时段的最大产奶量 //#pragma comment(linker, "/STACK:102400000, 102400000") #include <a…
题目链接:http://poj.org/problem?id=3616 题目大意:给你时间N,还有M个区间每个区间a[i]都有开始时间.结束时间.生产效率(时间都不超过N),只能在给出的时间段内生产,要求合理安排时间求出最大生产价值. 解题思路:把区间按开始时间排序,于是有状态转移方程:dp[i]=max(dp[i],dp[j]+a[i].val)(前提是a[j].end+r<=a[i].start,i是区间的序号,j是i前面的区间) 相当于最大递增子序列的变形,写法差不多. 代码: #incl…
题目链接 http://poj.org/problem?id=3616 题意:在一个农场里,在长度为N个时间可以挤奶,但只能挤M次,且每挤一次就要休息t分钟: 接下来给m组数据表示挤奶的时间与奶量求最大挤奶量 看似很复杂其实就是求大递增序列即可,先将M次挤奶进行排序按照end从小到大排序然后判断s[i].sta-r>=s[j].end时可以加上. #include <iostream> #include <algorithm> #include <cstring>…
Software Company Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1112   Accepted: 482 Description A software developing company has been assigned two programming projects. As both projects are within the same contract, both must be hande…
                                                                                             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…