Skip to content

Latest commit

 

History

History

roadrage

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

There are N cars placed along a (road) positive X-axis (say at co-ordinates x1=1, x2=5, x3=3 etc.)

Each car has a certain constant velocity (say v1=6, v2=3, v3=1 etc.).

If we just start this system at t=0, and keep it running till t=oo, what will be the total number of overtakes that will occur?

Input Format:

N # Number of test cases

P1 # Number of cars in the test case.

X1 V1 # Starting position of first car and velocity.

X2 V2 # Starting position of second car and velocity.

.

.

.

.

XP1 VP1 # Starting position of car P1 and velocity.

Example

SAMPLE INPUT

2
3
1 6
5 3
3 1
10
4 8
2 2
3 10
6 9
1 5
10 7
7 4
8 3
5 1
9 6


SAMPLE OUTPUT
2
22