Комментарии
На dev_ankitpAll CSES Problems Editorial [ONGOING], 6 лет назад
+3

If we maintain a prefix sum array of the original array our problem breaks down to finding L & R points (where L <= R) such that prefSm[R]-prefSum[L-1] is maximum possible and R-L+1 (all elements within) is between a to b. We can iterate over all points (i = 1 to N) and fix R=i after that we just need to find a point L which is at least a distance away but not more than b distance.

We can do this easily in quadratic time but to do so in linear time we will need to use the idea of sliding window maximum problem. We can delay pushing elements to our sliding window by a (keeping the intended gap of a) and maintain a size keeping only b-a+1 elements in the window hence fulfilling our second constraint.

Now look at my solution, hopefully you will be able to understand it now: https://github.com/ankitpriyarup/CSES_ProblemSet_Solution/blob/master/2%20Sorting_and_Searching.md#maximum-subarray-sum-ii

На dev_ankitpAll CSES Problems Editorial [ONGOING], 6 лет назад
0

I'll keep updating the repository as I'll do more problems. For additional range query editorial you can refer: https://mirror.codeforces.com/blog/entry/77128

На dev_ankitpAll CSES Problems Editorial [ONGOING], 6 лет назад
0

Thanks! I'll add reference links soon.

На Noob-ita-coderProblem from CSES, 6 лет назад
0

prev has no use in that question, I was doing CSES problems in a sequence and one question before that wanted you to find shortest path nodes so for that I used prev. I've made all my CSES submissions public to github if you want to checkout that question refer: https://mirror.codeforces.com/blog/entry/77863

На Noob-ita-coderProblem from CSES, 6 лет назад
+4

I've solved the same problem recently with coincidentally the same idea as your's, here's my AC submission. https://paste.ubuntu.com/p/cKqC9Gfv6S/

During compiling use this time g++ -std=c++17 cprog.cpp

Then after execution last line will show:
g++ -std=c++17 cprog.cpp 1.31s user 0.10s system 99% cpu 1.415 total

I personally like this over writing some code

Count me in :D

0

Seems interesting, I've never heard of such data structure can you share implementation?

+6

Okay point taken!

Edit: Point taken jeez.. Probably those who are pupil or below shouldn't be allowed to post something (They can comment however). Just a thought don't bash on me now XD

На ZenekMartyniukhow is it possible ?, 6 лет назад
+1

Funniest thing I've seen whole day XD