DCP-412: Black cat and Jumping Power Back to All Problems

Easy Beginners Problems > Ad-hoc


**Black cat** are very special and have much more power. **Bittu** is not a black cat, so it has limited power. it has jumping power **P**,which means that it can jump forward to **at most P** distance. ![enter image description here][1] Now, **Bittu** is facing difficulty in crossing river of width **R**. There are some stones at certain distances from left side of the river. But some stones are separated by very longer distance that Bittu can not jump over it using its jumping power. If the distance to the next stone is found to be **X**, then Bittu needs at least **X** jumping power to be able to jump over and go there.<br> You are given the distances of stones from the left side of the river. Your task is to determine least amount of jumping power Bittu needs to increase so that it can goes to right side of the river. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases. Each test cases starts with three space separated integers **N (0<=N<=100)** , **R(1<=R<=10^9)** and **P (1<=P<=10^9)**, denoting total stones in the river, width of the river and initial jumping power of Bittu respectively (You may safely assume that left side of the river, stone placement and right side of the river forms a straight line).Then there will be N space separated integers **X (1<=X<=R-1)** denoting distance of stone from the left side of the river.( Distances are given arbitrary and there may be two stones at the same distance ) Output: ------- For each case of input, output an integer denoting total jumping power Bittu needs to increase in order to be able to go right side of the river. Sample Input ------------ 1 2 10 4 5 8 Sample Output ------------- 1 **Explanation of sample:**<br> Bittu needs jumping power of at least 5 to reach first stone. After that it needs jumping power of at least 3 to reach another stone. Then, it needs jumping power at least 2 to reach right side of the river. As it has jumping power of 4 already. So, If it increases current jumping power by 1, then it could reach the right side of the river easily. [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/38a5c9ff-757b-c0b0-539f-08d558d34f05_02d3c2b6ebe346c3abeed6dd626b4651_W170xH113.jpg


Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

118/782

Solve/Submission

Ranking

# User Language Timing
01 m_arif Cpp14 0.00s
02 Puja1409 Cpp14 0.00s
03 badhansen123 Cpp 0.00s
04 subhashis_cse Cpp 0.00s
05 zerocool Cpp 0.00s
06 mhiceiuk Cpp 0.00s
07 haasib Cpp 0.00s
08 Jisancse Cpp14 0.00s
09 tariqiitju Cpp14 0.00s
10 Biprodas Cpp14 0.00s
11 robin_aust Cpp 0.00s
12 prodipdatta7 Cpp 0.00s
13 shahincsejnu Cpp 0.00s
14 shishir09 Cpp14 0.00s
15 Shamim_A Cpp 0.00s
16 rayhan50001 Cpp 0.00s
17 yasirnabil534 Cpp 0.00s
18 shamimjucse Cpp 0.00s
19 t0whid Cpp 0.00s
20 Suhi31 Cpp 0.00s
21 pulak_ict_mbstu Cpp 0.00s
22 kakarotto Cpp 0.00s
23 afzalul Cpp 0.00s
24 a_rahman Cpp 0.00s
25 marineCoder Cpp 0.00s
26 motaleb_ICT Cpp 0.00s
27 prottoy919 Cpp 0.00s
28 Sajal_Deb Cpp 0.00s
29 Dhrubo020 Cpp 0.00s
30 Taran Cpp14 0.00s
31 srijonsbzsifat Cpp 0.00s
32 Riad_IIT7 Cpp14 0.00s
33 AlaminJust Cpp 0.00s
34 asma_chy Cpp14 0.00s
35 inam Cpp14 0.00s
36 amir_hamza Cpp14 0.00s
37 mepromee Cpp 0.00s
38 SakibAlamin Cpp 0.00s
39 DynamicOvi Cpp 0.00s
40 aaman007 Cpp 0.00s
41 Jantamanta14 Cpp 0.00s
42 Maruf_Robin Cpp 0.00s
43 abu_rifat Cpp 0.00s
44 _GhOstMan_ Cpp 0.00s
45 bu_hridoy Cpp 0.00s
46 tlcakash Cpp 0.00s
47 Sourav_biswas_santo Cpp 0.00s
48 Mimsad Cpp 0.00s
49 RAJ0RSHI Cpp 0.00s
50 hmsayem Cpp 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support