Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Mustafa wants to cross a dungeon. The dungeon has N cells, and in every cell, there are M monsters. To cross each cell he
Mustafa wants to cross a dungeon. The dungeon has N cells, and in every cell, there are M monsters. To cross each cell he has to kill one monster, on killing the monster, he loses the strength equal to that of the monster and gains some confidence which adds up in his strength and he proceeds to the next cell. Mustafa can only kill a monster if his strength is greater than or equal to the strength of the monster. Help him find the minimum strength he must have in the beginning so that he can cross N cells. Eg input: N=3 M=3 P= 325 891 476 C=111 111 111 C= 111 111 111 Output: 5 Explanation: 4 Let strength mustafa be s=5 Mustafa kills 2nd monster in first cell gains the confidence equal to 1.(s=4) Mustafa then kills 3rd Monster in second cell and gains confidence equal to 1. (s=4) Mustafa then kills 1st monster in third cell and gains confidence equal to 1. (s=1) So s=5 is the minimum strength required to cross the dungeon.
Step by Step Solution
★★★★★
3.50 Rating (180 Votes )
There are 3 Steps involved in it
Step: 1
To find the minimum strength Mustafa must have in the beginning to cross N cells we can use a binary ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started