forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHEFEZQ.c
38 lines (34 loc) · 747 Bytes
/
CHEFEZQ.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
int main() {
long int t, a, b;
scanf("%ld", & t);
for (long int z = 0; z < t; z++) {
scanf("%ld %ld", & a, & b);
long int arr[a];
for (long int i = 0; i < a; i++) {
scanf("%ld", & arr[i]);
}
if (arr[0] < b) {
printf("%ld\n",1);
} else if (a == 1) {
printf("%ld\n",((arr[0] / b) + 1));
} else {
long int s = arr[0] - b;
for (long int m = 1; m < a; m++) {
arr[m] = arr[m] + s;
if (arr[m] < b) {
printf("%ld\n",m+1);
break;
} else {
s = arr[m] - b;
if(m==a-1 && s>b)
{
printf("%ld\n",m+(s/b)+2);
break;
}
}
}
}
}
return 0;
}