poj3171 Cleaning Shifts[DP]】的更多相关文章

https://vjudge.net/problem/POJ-3171.(有价值的区间全覆盖问题) (lyd例题)朴素DP很好想,$f[i]$表示将右端点从小到大排序后从$L$(要求覆盖的大区间)到第$i$个区间的右端点都覆盖完成时最小化费.无解则为INF.然后利用排序.右端点单调性,每次枚举前面dp过的右端点落在现在左端点及其右侧(或相邻)的,去最小dp值加上现在费用.然后$O(n^2)$就可以水过啦..因为常数特别小,数据也才1e4嘛..优化的话因为每次查的都是一段区间里的右端点最值,所以线…
题目大意.N个区间覆盖[T1,T2]及相应的代价S,求从区间M到E的所有覆盖的最小代价是多少. (1 <= N <= 10,000).(0 <= M <= E <= 86,399). 思路是DP,首先将每一个区间依照T2从小到大排序,设dp(k)为从m覆盖到k所需最小代价,则有 dp(T2[i]) = min(dp(T2[i]), {dp(j) + Si,  T1[i] - 1<=j <= T2[i]}),对于 {dp(j) + Si,  T1[i] - 1<…
Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4422   Accepted: 1482 Description Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer…
题目:http://poj.org/problem?id=3171 题意:给你n个区间[a,b],每个区间都有一个费用c,要你用最小的费用覆盖区间[M,E] 分析:经典的区间覆盖问题,百度可以搜到这个专题. 线段覆盖问题一般考虑贪心和DP,但是每个区间又有了一个费用c,本渣觉得贪心貌似不太行(不知道神犇门有木有贪心解法),然后便考虑DP 设f[i]表示覆盖[M,i]的最小总费用 那么有f[t[i].a]=min(f[j]+t[i].c) t[i].a-1<=j<=t[i].b-1 那么ans=…
传送门 题目大意 有一个大区间和n个小区间,每个小区间都有一个代价,求最少付出多少代价可以使得小区间完全覆盖大区间. 分析为了方便起见我们先将s变为2,其它的位置都对应更改以便后期处理.我们考虑以t1为第一关键字,t2为第二关键字将所有奶牛排序.用dp[i][j]表示考虑到第i只牛,覆盖到点j最少需要多少钱.我们可以将i这一维去掉,则dp[j]=min{dp[j],dp[j'](t1-1<=j'<=t2-1)}.然后进行线段树优化就可以了. 代码 #include<iostream>…
题意 POJ2376 Cleaning Shifts 0x50「动态规划」例题 http://bailian.openjudge.cn/practice/2376 总时间限制: 1000ms 内存限制: 65536kB 描述 Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one c…
Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 32561   Accepted: 7972 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one co…
[Usaco2005 Dec] Cleaning Shifts 清理牛棚 题目描述 Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer John, the most obliging of farmers, has no choice but hire some of th…
Cleaning Shifts 题目连接: http://poj.org/problem?id=2376 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided…
Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2743   Accepted: 955 Description Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer J…