求助
查看原帖
求助
988099
_X_M_楼主2024/5/27 21:22

本人代码

#include <bits/stdc++.h>
using namespace std;
int n, dist, p[100010];
int main()
{
    cin >> n >> dist;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 3; i <= n; i++)
    {
        if (p[i] - p[i - 2] <= dist) ans++;
    }
    cout << ans << endl;
    return 0;
}

评测结果 哪里错了?请大佬们帮忙指正。

2024/5/27 21:22
加载中...