Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Last active July 24, 2017 21:42
Show Gist options
  • Save MohamedTaha98/3c38e26cb883f5633eda3ba6bdff979b to your computer and use it in GitHub Desktop.
Save MohamedTaha98/3c38e26cb883f5633eda3ba6bdff979b to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main() {
long long n, c, words = 1;
cin >> n >> c;
long ar[n];
for (int i = 0; i < n; i++)
cin >> ar[i];
for (int i = 0; i < n - 1; i++) {
if (ar[i + 1] - ar[i] <= c)
words++;
else
words = 1;
}
cout << words << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment