question Educational Codeforces Round 76 (Rated for Div. 2) D-Yet Another Monster Killing Problem
I am not able to understand which test case is failing any testcase would be highly helpful ..
I have put the following conditions *if maximum power of hero is less than maximum power of monsters then directly print -1 and exit
*else answer exists we iterate throughout and we create the bst array which is as described in the editorial.Using which we check the 2 conditions :-
--->if maximum in a our range is greater than our hero's power then we break and add a count to our days
--->if we have reached the hero with highest endurance and have exhausted him too then we again break and add a count to our days
I believe this covers all the possibilities ..
please help me .
Thanks in Advance
EDIT -- Now it is working
GUYS IT IS NOW WORKING THE ERROR WAS THAT I HAD INCREMENTED THE INDEX OF HEROES ONLY BY 1 EACH TIME WHICH DID NOT COVER ALL THE CASES. I HAD TO INCREMENT THE INDEX OF HEROES TILL I FOUND ONE WITH HIGHER ENDURANCE.
THANKS A LOT EVERYONE FOR YOUR REPLIES.
I HAVE UPLOADED THE CHANGES YOU CAN SEE
Auto comment: topic has been updated by Sachit_Jaggi (previous revision, new revision, compare).
Auto comment: topic has been updated by Sachit_Jaggi (previous revision, new revision, compare).
I have implemented the same approach and got it accepted. The basic idea being start with minimum endurance(1) and try to increase it until the power of the hero is sufficient enough to kill the target monster and if u are not able to find any such endurance of positive length simply print -1 and terminate the program. U can find my solution here. 67199296 https://codeforces.net/contest/1257/submission/67199296
This is the same approach I used,maybe hearing my idea can help you somehow :) What I did was I had the heroes as pairs (Strenght, Endurance) and I sorted this, also I had an array of the maximum endurance for every range [i, m — 1]. What I did was the same as you for going trought the monsters and updating the maximum (Most Powerful Monster). But the way I looked for a heroe that had Stength >= Most Powerful Monster and Endurance >= The number of monsters I was killing with this Heroe was:
This is my submission: https://codeforces.net/contest/1257/submission/69544960 , hope it can help you! :)
Nice explanation!
Auto comment: topic has been updated by Sachit_Jaggi (previous revision, new revision, compare).