Maximize Subarray Length to Mode Frequency Ratio

Revision en1, by bihariforces, 2026-04-30 11:02:04

You are given an array $$$a$$$ of length $$$n$$$.

For any subarray, define its mode frequency as the maximum number of occurrences of any value within this subarray.

Find the maximum value of

$$$ \frac{\text{length of subarray}}{\text{mode frequency}} $$$

over all subarrays.

Constraints: $$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le a_i \le n$$$.

Print the maximum possible value of the expression. Your answer will be accepted if its absolute or relative error does not exceed $$$10^{-6}$$$.

Give this interesting problem a try!

Tags problem

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English bihariforces 2026-04-30 11:02:04 571 Initial revision (published)