The Selection
CodeChefOpen on judge ↗
You are given $N$ integers $A_1,A_2,...,A_N$. You are also given $Q$ queries. Each query $i$ $(1\leq i\leq Q)$ is of the following type: $L_i$ $R_i$ $X_i:$ meaning, add the value $X_i$ to all the integers in the array whose indices lie in the range $[L_i,R_i]$. Your task is to tell the maximum possible sum of all the elements of the array if you are allowed to choose at most $K$ $(\leq Q)$ queri
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