Codeforces
CF Step
Youtube Linkedin Discord Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Hints : Counting Prefixes

Come up with an O(n) algorithm to compute the answer when the sum of elements is fixed to s.
Stars and Bars would be used to solve the version with a fixed sum.