Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- //INPUT ...
- int N, K;
- cin >> N >> K;
- int Array[N];
- for (int i = 0; i < N; i++)
- cin >> Array[i];
- //Counting Number of Partitions
- int Count[N], Loc = 0,i=0,count=0;
- memset(Count, 0, N * sizeof(int));
- while(i<N-1)
- {
- if((Array[i+1]-Array[i])==K)
- count++;
- else
- {
- Count[Loc++]=count+1;
- count=0;
- }
- i++;
- }
- cout<<count<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement