This is Code Apocalypse !!!
Practice
5 (1 votes)
Medium
Problem
79% Success 366 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

This is CODE APOCALYPSE!! People are fighting against each other ,not for food ,money or life but for points. There are n people and each of them is fighting for some number of points.

Now you will be given q queries containing l and r. You have to tell the maximum number of people who are fighting for same number of point from l to r.

INPUT

First line contains a integer t denoting the number of test cases.

Every first line of each test case contains n and q where n are the number of people and q is the number of queries.

Every second line of test case contains n space separated integer ai denoting the point in non decreasing order.

Next q lines contains two integer l and r.

OUTPUT

For every q queries you have to print the maximum number of people fighting for same number of points in a new line.

CONSTRAINT

1<=n,q<=105

1<=ai<=106

1<=l<=r<=n

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
5 votes
Tags:
Data StructuresMediumSegment Trees
Points:50
6 votes
Tags:
Advanced Data StructuresSegment TreesC++Data Structures
Points:50
Tags:
Data StructuresMediumSegment Trees
Editorial

No editorial available for this problem.