Sequence
Time limit1.5sMemory limit1024 MB
Given an array of length N (up to 5 x 10^5), find the largest count of a median value over all subarrays, where the medians are the middle one or two sorted elements.
- Level
Hard9 of 10
- Topics
- Array, Divide and conquer, Prefix sum
- Solved
- No attempts yet
Problem
In the realm of APIO, a young and brilliant student named Alice found a sequence of length : , , , . She wants to share some of her discoveries with you. First, here are some definitions.
- Define as , the number of occurrences of in .
- Define the set of medians of a non-empty integer sequence as . Alice computes it in two steps.
- First, sort in ascending order to get .
- Then .
- For example, , , and .
Alice wants the maximum of over all , where is . She already has the answer and wants you to write a program that verifies it.