题目链接: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…
大致题意:给出一队士兵的身高,一开始不是按身高排序的.要求最少的人出列,使原序列的士兵的身高先递增后递减. 求递增和递减不难想到递增子序列,要求最少的人出列,也就是原队列的人要最多. 1 2 3 4 5 4 3 2 1 这个序列从左至右看前半部分是递增,从右至左看前半部分也是递增.所以我们先把从左只右和从右至左的LIS分别求出来. 如果结果是这样的: A[i]={1.86 1.86 1.30621 2 1.4 1 1.97 2.2} //原队列 a[i]={1 1 1 2 2 1 3 4} b[…
传送门: 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…
题意:在给予的N个时间里,奶牛Bessie在M个时间段里进行产奶,但是每次产奶后都要休息R个时间 M个时间段里,分别有开始时间start和结束时间end,和该时间段里产奶的效率efficiency 求问,应该如何选择哪些时间段进行产奶,才能使得效率最大化 我的错误做法:设D[i]为到时间i以内,所能够产奶的最大量,从而d[i] = max(d[i-1], d[st[k]]+ef[k]); 最终还是TLE了,由于N最大为1000000,且k最大为1000,所以综合还是太花费时间了 正确思路:我看到…
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard output: standard The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-t…
题目链接 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>…
题目链接: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…
                                                                                             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…
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 ≤…
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…