dimriXD's blog

By dimriXD, history, 3 months ago, In English,

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.

Please help if there is a flaw in my logic or I missed something in the code. I shall be really thankful to you. Please help.

 
 
 
 

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    3 months ago, # ^ |
    Rev. 5   Vote: I like it 0 Vote: I do not like it

    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?

    • »
      »
      »
      3 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      The player's strength is already greater than 1 and 2. So all the dragons will be defeated straight away.

      • »
        »
        »
        »
        3 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks, initially I thought if bonus is 0 then we need to subtract strength of the hero, my bad, thanks for helping!