bzoj1689 [Usaco2005 Open] Muddy roads 泥泞的路
Description
Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contains (1 <= N <= 10,000) mud pools. Farmer John has a collection of wooden planks of length L that he can use to bridge these mud pools. He can overlap planks and the ends do not need to be anchored on the ground. However, he must cover each pool completely. Given the mud pools, help FJ figure out the minimum number of planks he needs in order to completely cover all the mud pools.
Input
* Line 1: Two space-separated integers: N and L * Lines 2..N+1: Line i+1 contains two space-separated integers: s_i and e_i (0 <= s_i < e_i <= 1,000,000,000) that specify the start and end points of a mud pool along the road. The mud pools will not overlap. These numbers specify points, so a mud pool from 35 to 39 can be covered by a single board of length 4. Mud pools at (3,6) and (6,9) are not considered to overlap.
Output
* Line 1: The miminum number of planks FJ needs to use.
Sample Input
1 6
13 17
8 12
Sample Output
HINT
sb模拟题
用pair<int,int>写的……感觉骚的没朋友
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m,l,ans;
pa a[10010];
int main()
{
n=read();m=read();
for (int i=1;i<=n;i++)
{
a[i].first=read();
a[i].second=read()-1;
}
sort(a+1,a+n+1);
for (int i=1;i<=n;i++)
{
l=max(l,a[i].first-1);
int len=a[i].second-a[i].first;
ans+=len/m;
l+=(len/m)*m;
while (l<a[i].second)l+=m,ans++;
}
printf("%d\n",ans);
}
bzoj1689 [Usaco2005 Open] Muddy roads 泥泞的路的更多相关文章
- bzoj1689 / P1589 [Usaco2005 Open] Muddy roads 泥泞的路
P1589 [Usaco2005 Open] Muddy roads 泥泞的路 简单的模拟题. 给水坑排个序,蓝后贪心放板子. 注意边界细节. #include<iostream> #in ...
- bzoj 1689: [Usaco2005 Open] Muddy roads 泥泞的路
1689: [Usaco2005 Open] Muddy roads 泥泞的路 Description Farmer John has a problem: the dirt road from hi ...
- 【BZOJ】1689: [Usaco2005 Open] Muddy roads 泥泞的路(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1689 一开始我也想到了贪心,,,策略是如果两个连续的水池的距离小于l的话,那么就将他们链接起来,,, ...
- P1689: [Usaco2005 Open] Muddy roads 泥泞的路
水题,模拟就行了,别忘了L>=r的时候直接更新下一个的L然后continue type node=record l,r:longint; end; var n,l,i,ans:longint; ...
- bzoj 1689: [Usaco2005 Open] Muddy roads 泥泞的路【贪心】
按左端点排序,贪心的选即可 #include<iostream> #include<cstdio> #include<algorithm> using namesp ...
- BZOJ1689: [Usaco2005 Open] Muddy roads
1689: [Usaco2005 Open] Muddy roads Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 147 Solved: 107[Su ...
- bzoj 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 最小点覆盖
链接 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 思路 这就是个上一篇的稍微麻烦版(是变脸版,其实没麻烦) 用边长为1的模板覆盖地图上的没有长草的土地,不能覆盖草地 ...
- BZOJ 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场
Description 大雨侵袭了奶牛们的牧场.牧场是一个R * C的矩形,其中1≤R,C≤50.大雨将没有长草的土地弄得泥泞不堪,可是小心的奶牛们不想在吃草的时候弄脏她们的蹄子. 为了防止她们的蹄 ...
- [Usaco2005 Jan]Muddy Fields泥泞的牧场
Description 雨连续不断的击打了放牛的牧场,一个R行C列的格子(1<=R<=50,1<=C<=50).虽然这对草来说是件好事,但这却使得一些没有草遮盖的土地变得很泥泞 ...
随机推荐
- bzoj1753 [Usaco2005 qua]Who's in the Middle
Description FJ is surveying his herd to find the most average cow. He wants to know how much milk th ...
- QQ聊天界面的布局和设计(IOS篇)-第二季
QQChat Layout - 第二季 本来第二季是快写好了, 也花了点功夫, 结果gitbook出了点问题, 给没掉了.有些细节可能会一带而过, 如有疑问, 相互交流进步~. 在第一季中我们完成了Q ...
- 04747_Java语言程序设计(一)_第5章_图形界面设计(一)
例5.1一个用JFrame类创建窗口的Java应用程序. import javax.swing.*; public class Example5_1 { public static void main ...
- Direct3D 对X模型载入
今天我们来学习Direct3D对模型的导入使用,Direct3D支持.X模型文件导入使用,.X文件是微软定义的3D模型文件格式,其中包含网格,动画,纹理等等一些信息. 目前3DS Max 和 Maya ...
- Exchange Server 2010升级到Exchange Server 2013概览
- 用函数式的 Swift 实现图片转字符画的功能
今天整理 Pocket 中待看的文章,看到这篇<Creating ASCII art in functional Swift>,讲解如何用 Swift 将图片转成 ASCII 字符.具体原 ...
- HTTP协议3之压缩--转
HTTP内容编码和HTTP压缩的区别 HTTP压缩,在HTTP协议中,其实是内容编码的一种. 在http协议中,可以对内容(也就是body部分)进行编码, 可以采用gzip这样的编码. 从而达到压缩的 ...
- 利用MetaWeblog API 自制博客发布小工具
博客园提供了诸多数据接口, 利用这些接口可以很容易的实现博客的发布,修改,删除等 1.需要引用一个DLL:为CookComputing.XmlRpcV2 2.新建一个类,在其中是一些要实现的东西,如: ...
- ASP.NET MVC:自定义 Route 生成小写 Url(转)
先给出本文中测试用的 controller: public class PersonsController : Controller { public ActionResult Query(strin ...
- 注册界面设计及实现之(三)SharedPerferences实现数据暂存
开发步骤: 创建一个SharedPerferences接口对象,并使用其putString方法放入相关的公共数据 将验证通过的注册账号写入到该文件中 将数据进行提交 给出客户提示 //Register ...