Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

### devil_17's blog

By devil_17, 5 weeks ago, ,

I was solving the problem 607A - Chain Reaction 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

 » 5 weeks ago, # | ← 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 : 2Your Output : 3
•  » » 5 weeks ago, # ^ |   +3 Thank you so much man! I knew I had made some silly mistake but couldn't figure it out.