#P7882. [Ynoi2006] rsrams
[Ynoi2006] rsrams
Problem Description
Given a sequence of length , you need to process queries. Each query gives , and the answer is:
$\sum\limits_{L=l}^r \sum\limits_{R=L}^r \sum\limits_{c=1}^n c\cdot \left[R-L+1<2\sum\limits_{i=L}^R [a_i=c] \right]$.
Here means that if the condition expression inside the brackets is true, then ; otherwise, .
Input Format
The first line contains two integers .
The second line contains integers .
The next lines each contain two integers , representing a query.
Output Format
Output lines. Each line contains one integer, representing the answer to each query.
3 2
1 1 2
1 3
2 3
6
3
Hint
Idea: zjjcth330, Solution: nzhtl1477&ccz181078, Code: ccz181078, Data: ccz181078.
Constraints: For of the testdata, , , , .
Translated by ChatGPT 5