A man is in jail and jumps X meters across the wall but due to slippery walls he falls Y meters after each jump. To escape from the jail, he has to cross 'N' walls, where height of each wall is given in an array.
Write a program(in C++) to find out the total no. of jumps he has to make to escape from the jail.
Answers
Answered by
1
You should write a program, first of all, you will add input format which will be the following:
1. An integer depicting X
2. An integer depicting Y
3. And an array of N integers which will be having the height of the wall
following will be the constraints:
1< = X <=109
1< = Y <= 105
and the output format will be the following:
The program should be able to return the total number of jumps which are required to escape.
for example there is a test case
sample input
10
1
1
10
the sample output will be
1
the explanation for this is:
that the activist can jump 10 meters high but also slides down by 1 meter and there is a 1 wall which he wants to jump and the height of the wall is also 10 meters. So when he jumps 10 meters in the first attempt he will be able to cross the wall easily in the first attempt.
1. An integer depicting X
2. An integer depicting Y
3. And an array of N integers which will be having the height of the wall
following will be the constraints:
1< = X <=109
1< = Y <= 105
and the output format will be the following:
The program should be able to return the total number of jumps which are required to escape.
for example there is a test case
sample input
10
1
1
10
the sample output will be
1
the explanation for this is:
that the activist can jump 10 meters high but also slides down by 1 meter and there is a 1 wall which he wants to jump and the height of the wall is also 10 meters. So when he jumps 10 meters in the first attempt he will be able to cross the wall easily in the first attempt.
Similar questions