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




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

Your feedback is our precious!

Or call +88 02 9853138 for support