BZOJ2287【POJ Challenge】The Disappearing Thing

answer:


1. I have seen something similar before, you can divide and conquer cdq

When l=r, there is still a remainder

So time is nmlogn space is mlogn

2. First of all, we can dp show the number of solutions for j

Let g[i][j] indicate that i cannot be selected, and indicate the number of options for j

Consider how to transfer

g[i][j+w[i]]=f[i][j+w[i]]-g[i][j]

This means that the number of solutions for j+w[i] can be calculated from the total number of solutions - the number of solutions with i

This is nm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325083770&siteId=291194637