CF924D.Contact ATC

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Arkady the air traffic controller is now working with nn planes in the air. All planes move along a straight coordinate axis with Arkady's station being at point 00 on it. The ii -th plane, small enough to be represented by a point, currently has a coordinate of xix_{i} and is moving with speed viv_{i} . It's guaranteed that xivi<0x_{i}·v_{i}<0 , i.e., all planes are moving towards the station.

Occasionally, the planes are affected by winds. With a wind of speed vwindv_{wind} (not necessarily positive or integral), the speed of the ii -th plane becomes vi+vwindv_{i}+v_{wind} .

According to weather report, the current wind has a steady speed falling inside the range [w,w][-w,w] (inclusive), but the exact value cannot be measured accurately since this value is rather small — smaller than the absolute value of speed of any plane.

Each plane should contact Arkady at the exact moment it passes above his station. And you are to help Arkady count the number of pairs of planes (i,j)(i,j) ( i<ji<j ) there are such that there is a possible value of wind speed, under which planes ii and jj contact Arkady at the same moment. This value needn't be the same across different pairs.

The wind speed is the same for all planes. You may assume that the wind has a steady speed and lasts arbitrarily long.

输入格式

The first line contains two integers nn and ww ( 1<=n<=1000001<=n<=100000 , 0<=w<1050<=w<10^{5} ) — the number of planes and the maximum wind speed.

The ii -th of the next nn lines contains two integers xix_{i} and viv_{i} ( 1<=xi<=1051<=|x_{i}|<=10^{5} , w+1<=vi<=105w+1<=|v_{i}|<=10^{5} , xivi<0x_{i}·v_{i}<0 ) — the initial position and speed of the ii -th plane.

Planes are pairwise distinct, that is, no pair of (i,j)(i,j) ( i<ji<j ) exists such that both xi=xjx_{i}=x_{j} and vi=vjv_{i}=v_{j} .

输出格式

Output a single integer — the number of unordered pairs of planes that can contact Arkady at the same moment.

输入输出样例

  • 输入#1

    5 1
    -3 2
    -3 3
    -1 2
    1 -3
    3 -5
    

    输出#1

    3
    
  • 输入#2

    6 1
    -3 2
    -2 2
    -1 2
    1 -2
    2 -2
    3 -2
    

    输出#2

    9
    

说明/提示

In the first example, the following 33 pairs of planes satisfy the requirements:

  • (2,5)(2,5) passes the station at time 3/43/4 with vwind=1v_{wind}=1 ;
  • (3,4)(3,4) passes the station at time 2/52/5 with vwind=1/2v_{wind}=1/2 ;
  • (3,5)(3,5) passes the station at time 4/74/7 with vwind=1/4v_{wind}=-1/4 .

In the second example, each of the 33 planes with negative coordinates can form a valid pair with each of the other 33 , totaling 99 pairs.

首页