POJ 3190 Stall Reservations贪心 Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obvi…
http://poj.org/problem?id=3190 Stall Reservations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3567   Accepted: 1276   Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be m…
Stall Reservations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7646   Accepted: 2710   Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time in…
Stall Reservations Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obviously, FJ must create a…
POJ 3190 题意: 一些奶牛要在指定的时间内挤牛奶,而一个机器只能同时对一个奶牛工作.给你每头奶牛的指定时间的区间(闭区间),问你最小需要多少机器.思路:先按奶牛要求的时间起始点进行从小到大排序,然后维护一个优先队列,里面以已经开始挤奶的奶牛的结束时间早为优先.然后每次只需要检查当前是否有奶牛的挤奶工作已经完成的机器即可,若有,则换那台机器进行工作.若没有,则加一台新的机器.注意:利用priority_queue<Node,vector<Node>,less<Node>…
http://poj.org/problem?id=3190 有n头挑剔的奶牛,只会在一个精确时间挤奶,而一头奶牛需要占用一个畜栏,并且不会和其他奶牛分享,每头奶牛都会有一个开始时间和结束时间,问至少需要多少个 畜栏  并且输出奶牛 i 在哪个畜栏 内挤奶. 首先应该对奶牛以开始时间从小到大排序,然后每次在开始的奶牛中选择结束时间最小的奶牛,这就需要用优先队列.看是否可以用这个畜栏,可以就加入到队列中,不可以就重新加一个畜栏. #include <iostream> #include <…
题意:给定N头奶牛,每头牛有固定的时间[a,b]让农夫去挤牛奶,农夫也只能在对应区间对指定奶牛进行挤奶, 求最少要多少个奶牛棚,使得在每个棚内的奶牛的挤奶时间不冲突. 思路:1.第一个想法就是贪心,对每头牛的挤奶时间[a,b]按a和b都从小排序,接着从左边开始找地一头牛, 然后再往右边找能够不冲突的牛再一个奶牛棚内.这个算法事件复杂度为n*n,由于最多5000头牛 所以后面还是TLE了. 2.还是自己太弱了,原来可以用优先队列进行优化,可以把当前冲突的牛放入优先队列,然后每次都能够冲优先队列 里…
题意:给出n头牛必须单独占用一台机器的时间段,问至少需要多少台机器 先按照每头牛的时间的x来排序,然后用一个优先队列(优先选取最小的)维护已经喂好的牛的最小的结束时间 比如现在优先队列里面有m头牛已经完成了饲喂, 对于第m+1头牛, 如果它的开始时间小于这m头牛里面的最小的结束时间,那么必须增加一台机器,同时把第m+1头牛放进队列 如果它的开始时间大于这m头牛里面的最小的结束时间,把当前队头弹出,再把m+1头牛放进去 #include<iostream> #include<cstdio&…
Stall Reservations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11002   Accepted: 3886   Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time i…
传送门:http://poj.org/problem?id=3190 Stall Reservations Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9173 Accepted: 3208 Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be mil…