單調佇列優化 dp
The only difference between easy and hard versions is the constraints.
Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n
consecutive pictures (with kittens, of course). Vova likes all these pictures, but some are more beautiful than the others: the
.
Vova wants to repost exactly x
pictures in such a way that:
- each segment of the news feed of at least k
- consecutive pictures has at least one picture reposted by Vova;
- the sum of beauty values of reposted pictures is maximum possible.
For example, if