当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3012:Travel around the world

题目描述
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 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.
输出解释
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.
输入样例
2 2
1 2
3 1
4 5 6
输出样例
2
2
提示
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.


来自杭电HDUOJ的附加信息
Recommend gaojie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3012

最后修改于 2020-10-25T22:59:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)