CF173E Camping Groups
Description
A club wants to take its members camping. In order to organize the event better the club directors decided to partition the members into several groups.
Club member $ i $ has a responsibility value $ r_{i} $ and an age value $ a_{i} $ . A group is a non-empty subset of club members with one member known as group leader. A group leader should be one of the most responsible members of the group (his responsibility value is not less than responsibility of any other group member) and his age absolute difference with any other group member should not exceed $ k $ .
Some club members are friends and want to be in the same group. They also like their group to be as large as possible. Now you should write a program that answers a series of questions like "What's the largest size of a group containing club member $ x $ and club member $ y $ ?". It's possible for $ x $ or $ y $ to be the group leader.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first query the largest group with members 3 and 5 is $ {1,3,4,5} $ where member 3 is the leader.
In the second query member 2 should be the leader so the group will be $ {1,2,3} $ .
In the third query the leader of the group should have age 3 so the only leader can be member 3, who is less responsible than member 2. So making a group is impossible.
The group for the fourth query is the same as first query.