### dimriXD's blog

By dimriXD, history, 5 years ago,

Hello guys!

I am new to codeforces, I stumbled upon 230A problem and my code is here. My basic idea was to create a list of list containing three things first->strength of dragon, second->bonus points, third->flag if this dragon is killed or not. Then I sorted according to bonus points and started incrementing kills if a dragon could be killed based on condition.

• 0

 » 5 years ago, # |   0 Sort according to dragon's strength. Check each time whether the player's new strength is greater than that of next dragon. If yes, update player's strength and repeat. Else, output no.
•  » » 5 years ago, # ^ | ← Rev. 5 →   0 thanks for replying, I hope I am doing the same in the code except for one thing(sort according to dragon's strength), if you got time would you please check out the code link? If I sort according to dragon's strength then won't it create a problem like: - 3 4 - 1 0 - 1 0 - 1 0 - 2 3 this is sorted according to dragon's strength then the answer would be 'no'? In other case we can kill dragon with strength 2 and get bonus of 3 and then kill all dragons? Answer would be 'yes' isn't it? Am I missing something?
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 The player's strength is already greater than 1 and 2. So all the dragons will be defeated straight away.
•  » » » » 5 years ago, # ^ |   0 Thanks, initially I thought if bonus is 0 then we need to subtract strength of the hero, my bad, thanks for helping!
 » 2 years ago, # |   +1 Why we need sorting here please ?
•  » » 2 years ago, # ^ |   0 Because Kirito first needs to fight the dragon that has the least strength to gain his strength, and then fight other dragons.
•  » » » 2 years ago, # ^ |   +1 Got it, Thanks Bro.
 » 2 years ago, # |   0 We need to make a pair of vectors and then sort one of them. The other vector would be sorted accordingly. You can see my submission to the problem, it may help. Submission
 » 20 months ago, # | ← Rev. 2 →   0 I am failing test case #6: 2 2 3 5 1 2 "wrong answer 1st words differ — expected: 'YES', found: 'NO'"Why the expected answer is YES when Kirito's initial strength is smaller that every dragon?Thanks in advance!
•  » » 20 months ago, # ^ |   0 Kirito's initial strength is 2. This is larger that the second dragon's strength, which is 1. You might want to reread the input format.
•  » » » 20 months ago, # ^ |   0 Thank you! My bad. I was parsing incorrectly the input :)
•  » » » 18 months ago, # ^ |   0 This is my solution for this problem: https://ideone.com/4QwCwt I used map to solve it. I really don't see anything wrong in it and it should work but I constantly keep getting wrong answer on test case 10. Can someone help please?
•  » » » » 16 months ago, # ^ |   0 The thing about hashmap is that it needs unique key. So if test case has two dragons with same strength,hashmap will fail
•  » » » » » 16 months ago, # ^ |   0 Yep, got it a long time ago, but thanks anyways.
 » 16 months ago, # |   0 My 104218672 is falling in test case 9.I think it should be YES, but the judge says that it is NO, can someone explain to me why is this NO?
•  » » 6 months ago, # ^ |   0 you should consider case in which dragon's strength is equal to kirito's strength.
•  » » 6 months ago, # ^ |   0 you are doing this s >= item.first, if i am not wrong, I checked your solution, but you have been told that the strength should be greater than the dragon and not greater than or equal to. So instead of s >= you will have to perform just s > item.first
 » 16 months ago, # | ← Rev. 2 →   0 sort