POJ2376 Cleaning Shifts 【贪心】】的更多相关文章

题意 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: 11542   Accepted: 3004 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…
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 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 the day into T shifts (1 <= T <= 1,000,000…
<pre name="code" class="html"> Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14425   Accepted: 3700 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleani…
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…
http://poj.org/problem?id=2376 john有n头牛做打扫工作,他想在t时间内每个时间都至少有一头牛在做打扫工作,第一头牛在1,最后一头牛在t时间,每一头牛工作都有一个开始时间和结束时间,现在让我们找出在每个时间点都有牛打扫的情况下,所用牛越少越好,不能满足输出-1. 首先按起点排序,起点相同就按结束时间长的排序,然后贪心,每次选择时满足      当前牛的开始时间<=上一头牛的结束时间加1,并且当前牛的结束时间最大的一个. 注意 : 不必覆盖只要能连接即可.(1 3…
https://vjudge.net/problem/POJ-2376 题意理解错了!!真是要仔细看题啊!! 看了poj的discuss才发现,如果前一头牛截止到3,那么下一头牛可以从4开始!!! #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath> #include<se…
题目大意: (不说牛了) 给出n个区间,选出个数最少的区间来覆盖区间[1,t].n,t都是给出的. 题目中默认情况是[1,x],[x+1,t]也是可以的.也就是两个相邻的区间之间可以是小区间的右端与大区间的左端相差1.这个是看题解才知道的. 解题思路: 贪心题的关键是找到贪心策略.但是这题的贪心策略没那么明显.并且贪心策略没有特定地去选择某一区间.这一题最重要的是要知道在什么情况下才需要增加一个区间. 首先是进行排序,按照区间的左端从小到大排序,左端相同的按照右端从小到大排. 从头开始遍历(只能…
题意:给定1-m的区间,然后给定n个小区间,用最少的小区间去覆盖1-m的区间,覆盖不了,输出-1. 析:一看就知道是贪心算法的区间覆盖,主要贪心策略是把左端点排序,如果左端点大于1无解,然后, 忽略小于1的部分(如果有的话),再找最长的区间,然后把这个区间的右端点作为下次寻找的起点, 再找最大区间,直到覆盖到最后. 注意:首先要判断好能不能覆盖,不能覆盖就结束,有可能会提前结束,也要做好判断,我就在这WA了好几次, 悲剧...其他的就比较简单了,不用说了. 代码如下: #include <ios…