Problem:-
Chetan has crush on a girl and purposes her but as girl is quite adventorous . So she will accept chetan puposal only if he can cross a river using one jump .
The river has stones placed and each stone has a maximum power associated with it which means if chetan lands on ith stone which has power then he can make another jump of length .Currently chetan is on left side of river and he has to cross the river with landing only on one stone . Print the minimum length of initial jump you should make such that you will finally land outside the field by using exactly one booster. Print the minimum length of jump he should make so that he will land on other side of river by using one stone .
INPUT FORMAT :
The first line contain the number of stones in the river .
Second line contain space separated integers representing the power of each stone A[1] , A[2], A[3]............ A[n] .
OUTPUT FORMAT :
Output the minimum length of jump so he will cross the river using one stone .
CONSTRAINTS:
1< N< 106
1< A[i] <106
The river has stones placed and each stone has a maximum power associated with it which means if chetan lands on ith stone which has power then he can make another jump of length .Currently chetan is on left side of river and he has to cross the river with landing only on one stone . Print the minimum length of initial jump you should make such that you will finally land outside the field by using exactly one booster. Print the minimum length of jump he should make so that he will land on other side of river by using one stone .
INPUT FORMAT :
The first line contain the number of stones in the river .
Second line contain space separated integers representing the power of each stone A[1] , A[2], A[3]............ A[n] .
OUTPUT FORMAT :
Output the minimum length of jump so he will cross the river using one stone .
CONSTRAINTS:
1< N< 106
1< A[i] <106
Explanation
He can cross the river by making jump of length 3 , 4 or 5 . So 3 is correct answer as we need smallest jump .
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:
#include<stdio.h>
2 Comments
👌👌
ReplyDeleteGood program
ReplyDelete