迷之错误
  • 板块P1589 泥泞路
  • 楼主轻绘
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/10/7 22:36
  • 上次更新2023/11/5 11:38:22
查看原帖
迷之错误
202606
轻绘楼主2020/10/7 22:36
#include<bits/stdc++.h>
using namespace std;
int n,ll,now,ans,len,l,r;
struct note{
	int x,y;
}a[20000];
bool cmp(note x,note y){
	if(x.x==x.y)
		return x.y<y.y;
	return x.x<y.x; 
}
int main(){
	scanf("%d%d",&n,&ll);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		int o=0;
		now=max(now,a[i].x);
		if((a[i].y-now)%ll!=0){
			o++;
		}
		o+=(a[i].y-now)/ll;
		if(o<=0){
			continue;
		}
		//printf("%d\n",o);
		now+=o*ll;
		ans+=o;
	}
	printf("%d",ans);
	return 0;
}

大佬帮忙看一下WA了6个点

2020/10/7 22:36
加载中...