牛客国庆集训派对Day1 E Eustia of the Tarnished Wings(排序)

版权声明:哈哈哈哈哈哈哈哈哈哈哈哦吼~~ https://blog.csdn.net/threeh20/article/details/82927648

https://www.nowcoder.com/acm/contest/201/E

排个序

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
#define LL long long int
LL a[1000100];
int main()
{
    int n, m;
    while (~scanf("%d%d", &n, &m))
    {
        for (int i = 0;i < n;i++)
            scanf("%lld", &a[i]);
        sort(a, a + n);
        int res = n;
        for (int i = 1;i < n;i++)
        {
            if (a[i] - m <= a[i - 1])
                res--;
        }
        printf("%d\n", res);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/threeh20/article/details/82927648