标签:des style blog http color io os ar for
1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cmath> 5 #include<algorithm> 6 #include<iostream> 7 using namespace std; 8 int n,L; 9 struct ken{int l,r;} a[10002]; 10 bool kp(const ken &i,const ken &j) {return i.l<j.l;} 11 void init() 12 { 13 scanf("%d%d",&n,&L); 14 int i; 15 for(i=1;i<=n;i++) 16 scanf("%d%d",&a[i].l,&a[i].r); 17 sort(a+1,a+n+1,kp); 18 } 19 void work() 20 { 21 int i,len=0,w=0,ans=0; 22 for(i=1;i<=n;i++) 23 {if(w>=a[i].r) continue; 24 w=max(a[i].l,w); 25 while(w<a[i].r) {ans++; w+=L;} 26 } 27 printf("%d\n",ans); 28 } 29 int main() 30 { 31 init(); work(); 32 return 0; 33 }
BZOJ1689: [Usaco2005 Open] Muddy roads
标签:des style blog http color io os ar for
原文地址:http://www.cnblogs.com/zyfzyf/p/3984399.html