#5050. [USACO12OPEN] Running Laps S

[USACO12OPEN] Running Laps S

题目描述

农夫约翰让他的 nn1n100,0001 \le n \le 100,000)头牛在长度为 cc 的跑道上进行跑 ll 圈的比赛,所有牛从同一起点,以不同的速度开始跑。直到当跑得最快的那一头牛跑完 ll 圈时,所有牛才同时停下。

约翰发现在跑圈过程中发生了几次“超越事件”。其定义是:在比赛结束前某时刻,奶牛 xx 已经超越了奶牛 yy 整整一圈,则称做一次“超越事件”。(注:至少一圈,超越了 12\frac{1}{2} 圈,或者超越了 14\frac{1}{4} 圈等等都不算。且对于同一对奶牛 (x,y)(x,y) 不会重复计算次数。)

约翰想知道比赛过程中发生了多少次“超越事件”。

(注:可能原文章表达有误或某些其他原因,各种翻译方式过来的题意都有问题,给人误导很大,这里是根据题目数据和样例解释写的正确的题意,而不是原文)

输入格式

第一行:三个整数:n,l,cn,l,c1l,c25,0001 \le l,c \le 25,000)。

第二行到第 n+1n+1 行:每行一个整数 viv_i,表示奶牛 ii 的速度(1vi1,000,0001 \le v_i \le 1,000,000)。

输出格式

第一行:一个整数,表示总共发生的“超越事件”的次数。

感谢@远藤沙椰 提供的翻译

输入输出样例 #1

输入 #1

4 2 100 
20 
100 
70 
1

输出 #1

4

说明/提示

There are 4 cows running 2 laps on a circular track of length 100. The speeds of the cows are 20, 100, 70, and 1.

The race lasts 2 units of time, since this is the time it takes the fastest cow (cow 2) to finish. Within that time, there are 4 crossing events: cow 2 overtakes cows 1 and 4, and cow 3 overtakes cows 1 and 4.