DCP-546: Please So Jao Baby Back to All Problems

Medium Search Techniques > Binary Search/Bisection


**Mr BBK** don’t fall into sleep before 2 PM. So, His mother suggested him to count numbers in reverse order. It is guaranteed that he fall into sleep if he counts at least 20000 numbers sequentially in reverse order. Every number have **Sleepiness** value. When he pronounce/call the number, he gains Sleepiness value of that number. If summation of Sleepiness value >= **K** , he fall into sleep. Counting a number takes one second. His target is to fall into sleep as early as possible. He wants help to find the **minimum time** needed to fall into sleep for Mr BBK. He can choose any number <= 20000 and starts counting numbers in reverse order sequentially. He stops counting automatically when he fall into sleep. Input: ------ This is a smaple input detail. Please put your input detail here. For example, Input starts with an integer **T (1<=50)**, denoting the number of test cases. Each case contains a non-negative integer **K**. The next line will contain **20000** integers separated by spaces, denoting the Sleepiness values of the numbers from 1 to 20000. **Constraints** 1<=Sleepiness value <= 20000 0<= K <= ( Sum of Sleepiness values from 1 to 20000 ) Output: ------- For each test case, print the minimum time needed to fall into sleep for Mr BBK. Sample Input ------------ 1 2546 8 50 74 59 31 73 45 79 24 10 41 66 93 43 88 4 28 30 41 13 4 70 10 58 61 34 100 79 17 36 98 27 13 68 11 34 80 50 80 22 68 73 94 37 86 46 29 92 95 58 2 54 9 45 69 91 25 97 31 4 23 67 50 25 2 54 78 9 29 34 99 82 36 14 66 15 64 37 26 70 16 95 30 2 18 96 6 5 52 99 89 24 6 83 53 67 17 38 39 45 **Note** : Sample input is only for testing your code, it contains only Sleepiness value up-to 100. Sample Output ------------- 50


Problem Setter:

Bir Bahadur Khatri

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

38/173

Solve/Submission

Ranking

# User Language Timing
01 tariqiitju Cpp 0.09s
02 Arnob114348 Cpp 0.10s
03 tahsin_protik Cpp 0.12s
04 siam009 Cpp 0.13s
05 feodorv C 0.13s
06 Chayti_Saha98 Cpp 0.13s
07 Bisnu039 Cpp 0.14s
08 Dead_Phoenix Cpp 0.15s
09 Pure_Protea Cpp14 0.15s
10 kissu__pari__na Cpp14 0.17s
11 MamunAmin Cpp 0.19s
12 subhashis_cse Cpp 0.20s
13 anikatahsin Cpp 0.20s
14 leenaiitju Cpp 0.21s
15 prodipdatta7 Cpp14 0.23s
16 sajjad_h Cpp 0.23s
17 not_good_enough Cpp 0.26s
18 Tasmim Cpp14 0.29s
19 rayhan50001 Cpp14 0.29s
20 Mhkhaled Cpp 0.29s
21 a_rahman Cpp 0.30s
22 sharifulalam Cpp 0.31s
23 SakibAlamin Cpp14 0.37s
24 aaman007 Cpp 0.38s
25 mepromee Cpp 0.38s
26 Sarwar05 Cpp14 0.43s
27 SAIF_IIT8_JU Cpp 0.45s
28 showmic Cpp 0.53s
29 hmsayem Cpp 0.54s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support