Chef and Array
Chef has an array $A$ of $N$ elements denoted by $A_{0}, A_{1}, \ldots, A_{N-1}$. He thinks about $M$ questions of following kind: "What is the maximum element among $A_{i}$ where $i$ lies between $min(x, y)$ and $max(x, y)$ both inclusive?" You have to help Chef to find out sum of answers of all the $M$ questions. Method of generation of values $x$ and $y$ for all $M$ questions: You are
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