Reminder: in case of any technical issues, you can use lightweight websites m1.codeforces.com, m2.codeforces.com or m3.codeforces.com ×

### asifthen00b's blog

By asifthen00b, history, 5 months ago, ,

Recently I tried to solve Loj-1339 and found some ideas.

The main problem is :

There are several communities in the city. Each community consists of some consecutive houses such that every house belongs to exactly one community. The houses are numbered from 1 to n, and the communities are numbered from 1 to c.

Now some inspectors want to find the strongest community considering all houses from i to j. A community is strongest if maximum houses in the range belong to this community. So, there can be more than one strongest community in the range. So, they want to know the number of houses that belong to the strongest community.

Each case starts with a line containing three integers n (1 ≤ n ≤ 105), c (1 ≤ c ≤ n) and q (1 ≤ q ≤ 50000). The next line contains n space separated integers (each between 1 and c) denoting the communities the houses belong to. You can assume that the input follows the restrictions given above, and there are exactly c communities.

Each of the next q lines contains two integers i and j (1 ≤ i ≤ j ≤ n) denoting that the inspectors are asking for the result considering houses from i to j (inclusive).

•  » » 5 months ago, # ^ | ← Rev. 2 →   0 suppose i have made a freq[] array where freq[1] = 4 , fre1[2] = 3, freq[3] = 3 . now after removing 2 times, the freq[1] becomes 2 and rest of them doesn't change , then how to find the maximum freq[] ?