3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 137 Solved: 89[Submit][Status][Discuss] Description Being a fan of all cold-weather sports (especially those involving cows), Farmer John wants to record a…
3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 55 Solved: 34[Submit][Status] Description Being a fan of all cold-weather sports (especially those involving cows), Farmer John wants to record as much of…
题意:给出n个区间[a,b),有2个记录器,每个记录器中存放的区间不能重叠.求2个记录器中最多可放多少个区间. 解法:贪心.只有1个记录器的做法详见--关于贪心算法的经典问题(算法效率 or 动态规划).而对于2个,就是在1个的基础上(按 bi 排序,选第一个与之前没有相交的区间)维护2个值,注意要好好for循环遍历一次O(n),若想着用while直接跳过一些区间很容易出错!!!另外,遍历时要先考虑能否把当前的区间接在之前右端点较右的记录器. 1 #include<cstdio> 2 #inc…
题意:给定平面上N个点和一个值D,要求在x轴上选出尽量少的点,使得对于给定的每个店,都有一个选出的点离它的欧几里德距离不超过D. 解法:先把问题转换成模型,把对平面的点满足条件的点在x轴的直线上可得到一个个区间,这样就是选最小的点覆盖所有的区间的问题了.我之前的一篇博文有较详细的解释:关于贪心算法的经典问题(算法效率 or 动态规划).代码实现我就不写了.…
题面 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 136 Solved: 90 [Submit][Status][Discuss] Description The cross-country skiing course at the winter Moolympics is described by an M x N grid of elevations (1 <= M,N <= 500), each elevation being in t…