← All problemsSign in

Sell Upto 2

CodeChefRating 1560Open on judge ↗

There are $N$ days, and the sell price of a watch on the $i$-th day is $A_i$. Initially you have $0$ watches. For each day from $1$ to $N$, the following events happen: - First, you acquire one watch for free on each day. - Next, you may choose to sell **upto $2$ watches** (that you own) for $A_i$ coins each. What is the maximum profit you can obtain by optimally selling items? ### Input - The

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start