题目描述:https://pycoder.blog.csdn.net/article/details/125025504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int mycmp(const void *a, const void *b)
{
int aa = *(int *)a;
int bb = *(int *)b;
return (aa - bb);
}
int main(void)
{
int n, m;
int time[1000] = {0};
int pre_time = -1024;
int res = 0;
scanf("%d %d", &n, &m);
int x, y;
for (int i = 0; i < n; i++) {
scanf("%d %d", &x, &y);
time[i] = x + y;
}
qsort(time, n, sizeof(time[0]), mycmp);
for (int i = 0; i < n; i++) {
if (time[i] - pre_time >= m) {
pre_time = time[i];
res++;
}
}
printf("%d\n", res);
return 0;
}