Sum of Max K Subarray
For a permutation $P$ of size $N$, and an integer $k \ (1 \le k \le N)$, define $f(P, k)$ as $\displaystyle{\sum_{i = 1}^{N - k + 1} \max(P_i, P_{i + 1}, P_{i + 2}, \ldots, P_{i + k - 1})}$, i.e. the sum of maximum elements in all $k$ - sized subarrays. Let $g(N, k)$ denote the number of permutations $P$ of size $N$ which have the maximum value of $f(P, k)$. Given an integer $N$, find the value
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start