Ada and the Staircase

Can pls someone explain why my code is not getting AC …its running fine for all outputs pls help;
problem link is->https://www.codechef.com/COOK99B/problems/ADASTAIR
Here’s my code:-

#include
using namespace std;
int steps(int n,int k)
{

int a[n],count=0,t,b=0;
t=k;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=1;i<n;i++)
{
if(a[i]-a[i-1]<=k)
{

    continue;
}

if(a[i]-a[i-1]>k)
{
k=t;
int d=a[i]-a[i-1];
// cout<<d<<" ";
while(a[i]-a[i-1]>k)
{

      a[i-1]=a[i-1]+k;
    // cout<<k;
      count++;

    // cout<<count<<" ";
  }

}
k=t;
}
return count;

}
int main() {
long long t;
int n,k;
cin>>t;
while(t–)
{
cin>>n;
cin>>k;
cout<<steps(n,k);
}
}

It seems that you don’t check the height of the first step - it may be unreachable from the ground.

Oh yeah ur right i just forgot that. thanks a lot bro…i understood my mistake

//