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

Автор devil_17, 4 года назад, По-английски

I was solving the problem 607A - Цепная реакция and got WA on test case 11. Here's my submission 82317236. dp[i] is basically the number of destroyed beacons if we consider the coordinates [0,i]. numBeacons[i] is the total number of beacons again in [0,i]. Please help me where I am wrong. Have been stuck in this problem for a while now.

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

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

try initializing ii by int ii = numBeacons[0]; instead of having int ii = 0;

since your loop that is evaluating the dp starts from 1 in cases where initial poisition of some Beacon is 0 the powers are being shifted (as ii is still 0). i.e. the instead of power of Beacon 1 power of Beacon 0 is being used and so on.

Example test case:

4
0 1
1 2
2 4
3 2

Actual ans : 2

Your Output : 3

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Thank you so much man! I knew I had made some silly mistake but couldn't figure it out.