F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Travel around the world

Time 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
2 2 1 2 3 1 4 5 6
 

Sample Output
2 2
 

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
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-06-26 21:52:08, Gzip enabled