Блог пользователя ManikantanV

Автор ManikantanV, 10 лет назад, По-английски

Hi! I am unable to detect the bug in my code problem "Ilya and sticks". I have covered separate cases for number of sticks (>=4,=3,=2,=1). Help is appreciated.Thanks

Code link:

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

»
10 лет назад, # |
Rev. 5   Проголосовать: нравится +1 Проголосовать: не нравится

i have corrected your code: this is the link that got AC.
as you can see i have added some segments of code like:

if ( modify[i] > 0 && modify[i] < 4 )
    modify[i] = 0;
else if ( modify[i] >= 4 )
    modify[i] -= 4;

this ensures that the number of modifies are minimal so in the every if that they are checked there will be no problem.
plus i changed the if statements that check modify, take a look.

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thanks :) .. i failed to apply greedy in the sense that it would be sensible to use modified sticks first to make rectangles in place of original length sticks.