### 000golabi's blog

By 000golabi, history, 14 months ago,

“N” people are standing in a line, we name them as a0, a1, ... aN.

The age of any subset of people is defined to be the sum of its individuals.

we want to kill the oldest subset of these N people in a way that for each pair of killed people “ai” and “aj”, the distance is between “p” and “q”.

0< p <= abs(I — j) <= q

p and q are positive numbers. N < 20,000

———-

The above is a problem I came to when designing time series in a charting library. I have converted the original problem into a more readable codeforces style. This will be calculated in each WebGL animation frame, It needs to be fast.

• +8

 » 14 months ago, # |   +57 Help me solve this real problem from my workplace.We want to kill the oldest subset of these N people in a way that....The above is a problem I came to when designing time series in a charting library... What a rollercoaster ride!
•  » » 14 months ago, # ^ |   +61 Guys, don't help this serial killer
•  » » » 14 months ago, # ^ |   0 I know alot of countries' populations are getting older but this is just excessive.
 » 14 months ago, # |   0 a0,a1,.....aN means there are N+1 people not N people.
 » 14 months ago, # |   +26 Can the "age" of any "people" be negative (or zero)? Are you sure that you want to get the subset of maximum sum instead of maximum count? I just looked up "time series", and think that it makes sense to ask for maximum count, but not sure what maximum sum is for. I suppose approximate solution is allowed? This is a "real-life" problem, after all. Actually, mathematical description is usually preferred. (Given a sequence of numbers,...) Background can be interesting to read sometimes, but it's usually more annoying. There's an obvious O(n^3) dynamic programming solution, and it can be optimized to O(n^2) with some effort. However in case there's some special condition on p or q (such as p<=10 or q<=10 or n/p<=10 or q/p<=10 ...) the algorithm can be more efficient. What's the real use case?
 » 14 months ago, # |   -18 Is this money heist?