A7891 | Race
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Today $s$ kilometer long auto race takes place in Berland. The track is represented by a straight line as long as $s$ kilometers. There are $n$ cars taking part in the race, all of them start simultaneously at the very beginning of the track. For every car is known its behavior — the system of segments on each of which the speed of the car is constant. The $j$ -th segment of the $i$ -th car is pair $(v_{i,j},t_{i,j})$ , where $v_{i,j}$ is the car's speed on the whole segment in kilometers per hour and $t_{i,j}$ is for how many hours the car had been driving at that speed. The segments are given in the order in which they are "being driven on" by the cars.
Your task is to find out how many times during the race some car managed to have a lead over another car. A lead is considered a situation when one car appears in front of another car. It is known, that all the leads happen instantly, i. e. there are no such time segment of positive length, during which some two cars drive "together". At one moment of time on one and the same point several leads may appear. In this case all of them should be taken individually. Meetings of cars at the start and finish are not considered to be counted as leads.
Your task is to find out how many times during the race some car managed to have a lead over another car. A lead is considered a situation when one car appears in front of another car. It is known, that all the leads happen instantly, i. e. there are no such time segment of positive length, during which some two cars drive "together". At one moment of time on one and the same point several leads may appear. In this case all of them should be taken individually. Meetings of cars at the start and finish are not considered to be counted as leads.
输入格式
The first line contains two integers $n$ and $s$ ( $2<=n<=100,1<=s<=10^{6}$ ) — the number of cars and the length of the track in kilometers. Then follow $n$ lines — the description of the system of segments for each car. Every description starts with integer $k$ ( $1<=k<=100$ ) — the number of segments in the system. Then $k$ space-separated pairs of integers are written. Each pair is the speed and time of the segment. These integers are positive and don't exceed 1000. It is guaranteed, that the sum of lengths of all segments (in kilometers) for each car equals to $s$ ; and all the leads happen instantly.
输出格式
Print the single number — the number of times some car managed to take the lead over another car during the race.
输入输出样例
输入 #1
2 33 2 5 1 2 14 1 3 11
输出 #1
1
输入 #2
2 33 2 1 3 10 3 1 11 3
输出 #2
0
输入 #3
5 33 2 1 3 3 10 1 11 3 2 5 3 3 6 2 3 1 10 3 2 6 3 3 5
输出 #3
2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted