|
||||||||||
Travel around the worldTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 250 Accepted Submission(s): 19 Problem Description Around the World in 80 Days is a 2004 comedy film based on Jules Verne's novel of the same name. It stars Jackie Chan, Steve Coogan and C¨¦cile de France. The film is set in 19th-century Britain and centers on Phileas Fogg, here reimagined as an eccentric inventor and his efforts to circumnavigate the globe in 80 days. During the trip, he is accompanied by his Chinese valet, Passepartout. Robust is attracted by the film and planning for a tour around the world. There are N countries in the world,and Robust has assigned each country a value Fi for friendliness to tourist. Robust may go from country A to country B if the differences |Fa-Fb| is not bigger than M(FDL,Friendliness Difference Limit),or he would feel uncomfortable. Robust wishes to go to each country for exactly one time. Now he is choosing a country A to begin and a country B to end his tour(A!=B), he wonders how many different choices he could make, ie ,how many different pairs of (A,B) that would satify Robust¡¯s needs. Input Input contains multiple cases. Each test case starts with two integer N(2<=N<=10^4) ,M(1<=M<=10^6), indicating that there are N countries and the FDL. Follow by one lines contains N integers , the ith integer Fi(0<=Fi<=10^6) represents country i¡¯s friendliness to tourist. Output For each test case, output the different choices that Robust could make to choose a country to begin and a country to end his tour. Sample Input
Sample Output
Hint In sample 1,Robust ¡®s travel routes may be 1->2,2->1, the start-end pairs can be (1,2),(2,1),so the answer is 2. In sample 2,Robust¡¯s travel routes may be 1->2->3,3->2->1, the start-end pairs can be (1,3),(3,1)so the answer is 2. Source | ||||||||||
|