+ 2

Can anyone explain the possible logic and implementation for this problem ?

Actually ,I was solving a problem on codechef but most often I confuse how to design and the algorithm ,like where to use which type of sorting and searching algo , there fore I request you to please guide me in the reference of this problem on codechef . https://www.codechef.com/ZCOPRAC/problems/ZCO12002 Create : array for input start ,end ,uses of V wormholes and uses of W wormholes . Now as per I think , I would perform a linear search on start time contest by comparing it to each inputs of uses of V wormhole and would return the just greater than it and then compare that index with the elements in end time of contest and if the value if feasible for the inputs of uses of W wormholes , then add the time difference as per question t2-t1+1 in a separate array and finally print the least of them as answer . But this will be lot time consuming too What is the best way to think for such problem and implement the logics . Any suggestions is highly appreciated! Thanks! My language is Java

18th Nov 2019, 4:23 PM
Pranshu Ranjan
Pranshu Ranjan - avatar
3 Answers
+ 2
Hey Ace ,thanks for your reply i would follow your suggestions.
19th Nov 2019, 8:35 PM
Pranshu Ranjan
Pranshu Ranjan - avatar
0
Hey @Ace, here is the final correct solution i have implemented https://www.codechef.com/viewsolution/27955781 thanks for your suggestions
20th Nov 2019, 3:12 PM
Pranshu Ranjan
Pranshu Ranjan - avatar