Question: geeta wants to cross a river which does not have a brif = dge across it . she found some logs floationg on the waer

geeta wants to cross a river which does not have a brif=dge across it. she found some logs floationg on the waer and decides to cross the river by jumping from one log to other. She noticed something peculiar about the logs , they were all very alippery and someone had tied them together at the left end to hold them parallel to each other . Only the right end of th logs was good enough to get some grip , so she decided to cross the river by jumping from the right end pf one log to the next . However all the logs were of different length , ehich meant each jump she had to also go a certain distance left to right
geeta knows she could only jump a fixed distance to her roght and to her left. so if the logs were more apart than would to turn back and reach her styarting position. her first priority was to reach the opposite bank , but if left with no choice she would return back to her starting position
write a progrma to print the number of jumps geeta ,akes before reaching either the opposite end or her starting position
read the input from stdin and print the output to stdout , do moy=t wrie arbitary strings anywhere in the program
Contarint
n>=1, number of logs
x,y>=0, maximum distance geeta can jump in left and right direction
length of any log>=1
int step needed(int n , int x, int y, int a[])
sample input
n=5, x=3, y=5
a[]=1,6,5,4,1
output 6
where a represent length of log

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!