Concert
Time limit3sMemory limit1024 MB
After each point update to an array, find the contiguous range with the largest average, breaking ties by longer length, then by smaller left index.
- Level
Medium6 of 10
- Topics
- Segment tree, Array, Implementation
- Solved
- No attempts yet
Problem
The Dandae High School concert runs for days. students who can perform are numbered from 1 to , and student has skill . Every day, Junhyuk must pick at least one student to perform. Many spectators attend the concert, so the average skill of the performing students must be as large as possible. If two groups have the same average, the group with more students is better. If the group sizes are also equal, the group whose smallest number is smaller is better. The numbers of the performing students must also be consecutive.
Every morning, the skill of one student changes. The performance is in the afternoon, so it takes place after the change. For each day, find the numbers of the students Junhyuk should have perform.
Input
The first line contains .
The second line contains the integers separated by spaces.
The third line contains .
From the fourth line through line , each line contains and separated by a space, meaning that the skill of student changes to . ,
Output
For each day from 1 to , after that day's skill change, print and of the students that Junhyuk makes perform. Print one pair per line, separated by a space.