Skip to content

Commit 3c34223

Browse files
author
Zeocode
committed
ADASTAIR from codechef added
1 parent a7eec4f commit 3c34223

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Codechef/ADASTAIR.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int t;
7+
cin >> t;
8+
while(t--)
9+
{
10+
int n,k;
11+
cin >> n >> k;
12+
int a[n+1];
13+
a[0]=0;
14+
int count=0;
15+
for(int i=1;i<=n;i++)
16+
{
17+
cin >> a[i];
18+
19+
if(a[i]-a[i-1]>k)
20+
{
21+
count=count+(((a[i]-a[i-1])%k)==0?((a[i]-a[i-1])/k)-1:((a[i]-a[i-1])/k));
22+
}
23+
24+
}
25+
cout << count << endl;
26+
}
27+
}
28+

0 commit comments

Comments
 (0)