You were 9 episodes into Date a Live when you noticed that something was wrong. Who is this Kurumi character? That is when you realize you were watching Date a Live 2 the entire time. Now you need to go through the difficult ordeal of marathoning Date a Live through the night! Unfortunately, you cannot live without food through the entire night, and the anime streamer you are using still does not have a pause button. This means out of the total episodes, you need to skip some continuous episodes to go downstairs and eat something. Luckily, you have the overall ratings for the episodes, out of 10! The episode has a user rating of . In order to determine the best time to go make food, you have queries — each query asking the highest episode rating you can watch if you skip episodes to (inclusive) and how many episodes with this rating there are. It is guaranteed for any query, there will be at least one episode that you do not skip.
Input Specification
Line 1: two integers space separated, and .
Line 2: spaced integers, holding the rating for each episode, from to .
The next lines will contain integers and .
Output Specification
For each query, output two integers space separated. The first integer should be the highest rated episode that isn't skipped, and the second integer should be the number of episodes with this rating.
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
Sample Input
7 2
5 4 5 2 3 1 5
2 4
1 6
Sample Output
5 2
5 1
Explanation of Output for Sample Input
For the first query, episodes 2 to 4 will be skipped, leaving you with episode ratings: 5 x x x 3 1 5
. The highest rated episode is 5, and both episodes 1 and 7 have this rating.
Comments
Given that the maximum rating of an episode is 3628800 (10!), those episodes must have been trash.
UMM in, "The first integer should be the highest rated episode that isn't skipped, and the second integer should be the number of episodes with this rating." and "The highest rated episode is 5, and both episodes 1 and 7 have this rating." You say "the highest rated episode" meaning you're asking for the episode which has the highest rating and not the highest episode rating.
One day..my keyboard will fly out the window.
And you along with it.
do you wanna die
Do you want to solve sketchly park?
that's a fun one