Given: Alice has basket that can contain flowers of sizes $1$ to $A$.
Bob has basket that can contain flowers of sizes $B$ to $C$.
Its given that $B<A<C$.
All flowers of same size should be collected by same person.
It takes 1 minute for Alice and Bob to switch their places.
We have $N$ flowers, size of $i^{th}$ flower is $a[i]$.
To find: The minimum time needed to collect the flowers.
Example:
Let Alice range be $[1, 10]$.
Let Bob range be $[9, 12]$.
Let flowers be $\{10,12,10\}$.
If Alice is collecting the first flower, then they need to switch their places so that Bob can now collect 2nd flower. Now Bob can collect $3^{rd}$ flower of size $10$ but since Alice already picked flower of that size, they again switch places and Alice collects the last flower. Obviously this is not the best option to begin with Alice here, but I introduced it just to make the question clear.
2026-03-27 20:12:07.1774642327