Assistant Ranking
Time limit1sMemory limit512 MB
Given N assistants with two scores each and a tolerance K, find the maximum number of distinct ranks when a score gap above K forces a higher or equal rank.
Problem
The online retailer Amagoogsoftbook currently offers different so-called home assistants, which it wants to recommend to its customers. For this recommendation, they wish to rank all the assistants. The quality of this ranking is not very important: multiple assistants may even be assigned the same rank, but they wish to maximize the number of distinct ranks assigned, to lessen the decision fatigue of their customers.
To ensure that the ranking is not completely arbitrary, they have collected for each assistant two measurements and : the quality of the jokes the assistant can tell and how nice the compliments the assistant is able to give are (clearly these are the two most important aspects). These measurements are somewhat subjective, so they wish to ignore small differences in them. However, if for two given assistants and we have that or , the ranking of assistant must be the same or higher than the ranking of assistant . This rule may force two products to be given the same ranking, for example if assistant gives much better puns than assistant , while assistant gives the superior self-esteem boosts.
What is the maximum number of distinct ranks, taken over all possible rankings?
Input
The first line contains the integers and : the number of assistants and the measurement difference limit. The next line contains the integers . The next line contains the integers .
All measurements are between and .
Output
Output a single integer: the maximum number of distinct ranks.