动态规划&vector向量#include #include using namespace std;long long C(long long n){ return (n-1) * n / 2;}int main(){ long long n, d, count = 0; cin>> n>> d; vector v(n); for (int i = 0, j = 0; i cin>> v[i]; while (i >= 2 && (v[i] - v[j]) > d) { j++; } count += C(i - j); } cout return 0;}