Advertisement
Guest User

CP

a guest
Jun 22nd, 2018
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     //INPUT ...
  6.     int N, K;
  7.     cin >> N >> K;
  8.     int Array[N];
  9.     for (int i = 0; i < N; i++)
  10.         cin >> Array[i];
  11.  
  12.     //Counting Number of Partitions
  13.     int Count[N], Loc = 0,i=0,count=0;
  14.     memset(Count, 0, N * sizeof(int));
  15.     while(i<N-1)
  16.     {
  17.         if((Array[i+1]-Array[i])==K)
  18.              count++;
  19.            
  20.          else
  21.              {
  22.                   Count[Loc++]=count+1;
  23.                   count=0;
  24.              }
  25.          i++;
  26.     }  
  27.     cout<<count<<endl;      
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement