Question 6 - 100% Working Solution | Buy Now

Description

Winner Winner Alice and Bob are playing a game to decide who is better. They both play alternatively. Alice starts first. The subjects and the books are read sequentially. The rules of the game are as follows: - Both of them have N subjects. - Let array S denote the number of books in each subject. - Let array P denote the points for completing a book in a particular subject. - All books on one subject have the same points. In one move, a player has to complete the following steps: - They can skip all books of a subject if they want. They can keep skipping books till they want. Skip here means that the books of the subject become unavailable to read for both of them. As a result, the whole subject becomes unavailable. The player has the choice to skip subjects as long as he wants without losing his turn. - They read one book on a subject if it is available. On reading the book, the points of that person increase by P[i] where P[i] is the points for completing the book. So the number of books on that particular subject decreases by one. Note that he can read only one book in this step. The chance immediately goes to the other person just after he reads. If no book is available, the game ends. The other person continues with the remaining subjects and the remaining books. The game goes on alternatively until no book is available to read.
Question Image Question Image

All Testcases Passed ✔



Passcode Image Passcode Image

Solution

Please login to view the solution