我不是标题党
  • 板块灌水区
  • 楼主lucy2012
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/8/5 21:55
  • 上次更新2024/8/6 08:00:13
查看原帖
我不是标题党
1252442
lucy2012楼主2024/8/5 21:55

rt,求调 awaawa。

题目数据大小:1≤ai,bi,m≤1091\le a_i,b_i,m\le 10^9。

样例1:

输入:

4 5
1 10
5 1
6 2
7 2 

输出:

3

样例2:

输入:

5 3
1 1
2 30
3 10
3 1
5 3

输出:

3

代码:

#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010],b[100010],last,maxx;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if(a[i-1]+m<=a[i]+b[i]||i==1){
			if(last>maxx)
			    maxx=last;
			last=1;
		}else{
			last++;
		}
	}
	if(last>maxx)
	    maxx=last;
	cout<<maxx;
    return 0;
}
2024/8/5 21:55
加载中...