Title Description
n skills, abilities by the i-th W [i] damage, requires c [i] points of energy value, using L [i] times. Q times the existing inquiry, asking each time when not in use skills cj, there are cc-point energy, resulting in up to a few injuries.
data range
n,cc<=1000,l<=100,q<=300000.
Analytical title
backpack
First, the process F [i] [j] denotes the front i skills total energy of the j-th maximum damage, g [i] [j] denotes i - n j a total energy of these skills maximum damage.
When asked queries f [cj-1] [k] + g [cj + 1] [cc-k] maximum.
But found time complexity O (cc * q) 3e8, if the card may be too less.
Rule of Thirds separated using a <= 250 re-enumeration range within this range can be reduced to less than 1E8. Higher accuracy can be over water.