A11659 | Contact ATC
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Arkady the air traffic controller is now working with $n$ planes in the air. All planes move along a straight coordinate axis with Arkady's station being at point $0$ on it. The $i$ -th plane, small enough to be represented by a point, currently has a coordinate of $x_{i}$ and is moving with speed $v_{i}$ . It's guaranteed that $x_{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 $v_{wind}$ (not necessarily positive or integral), the speed of the $i$ -th plane becomes $v_{i}+v_{wind}$ .
According to weather report, the current wind has a steady speed falling inside the range $[-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$ ) there are such that there is a possible value of wind speed, under which planes $i$ and $j$ 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.
Occasionally, the planes are affected by winds. With a wind of speed $v_{wind}$ (not necessarily positive or integral), the speed of the $i$ -th plane becomes $v_{i}+v_{wind}$ .
According to weather report, the current wind has a steady speed falling inside the range $[-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$ ) there are such that there is a possible value of wind speed, under which planes $i$ and $j$ 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 $n$ and $w$ ( $1<=n<=100000$ , $0<=w<10^{5}$ ) — the number of planes and the maximum wind speed.
The $i$ -th of the next $n$ lines contains two integers $x_{i}$ and $v_{i}$ ( $1<=|x_{i}|<=10^{5}$ , $w+1<=|v_{i}|<=10^{5}$ , $x_{i}·v_{i}<0$ ) — the initial position and speed of the $i$ -th plane.
Planes are pairwise distinct, that is, no pair of $(i,j)$ ( $i<j$ ) exists such that both $x_{i}=x_{j}$ and $v_{i}=v_{j}$ .
The $i$ -th of the next $n$ lines contains two integers $x_{i}$ and $v_{i}$ ( $1<=|x_{i}|<=10^{5}$ , $w+1<=|v_{i}|<=10^{5}$ , $x_{i}·v_{i}<0$ ) — the initial position and speed of the $i$ -th plane.
Planes are pairwise distinct, that is, no pair of $(i,j)$ ( $i<j$ ) exists such that both $x_{i}=x_{j}$ and $v_{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 $3$ pairs of planes satisfy the requirements:
- $(2,5)$ passes the station at time $3/4$ with $v_{wind}=1$ ;
- $(3,4)$ passes the station at time $2/5$ with $v_{wind}=1/2$ ;
- $(3,5)$ passes the station at time $4/7$ with $v_{wind}=-1/4$ .
In the second example, each of the $3$ planes with negative coordinates can form a valid pair with each of the other $3$ , totaling $9$ pairs.
- $(2,5)$ passes the station at time $3/4$ with $v_{wind}=1$ ;
- $(3,4)$ passes the station at time $2/5$ with $v_{wind}=1/2$ ;
- $(3,5)$ passes the station at time $4/7$ with $v_{wind}=-1/4$ .
In the second example, each of the $3$ planes with negative coordinates can form a valid pair with each of the other $3$ , totaling $9$ pairs.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted