eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Particles

Particles

Two linear particle accelerators AAA and BBB, placed opposite to each other at a distance LLL apart, are propelling elementary particles. AAA is shooting xxx-particles, while BBB is shooting yyy-particles. The two kinds of particles are flying one opposing the other, and when an xxx-particle meets a yyy-particle, they collide and annihilate. One should be aware that an xxx-particle could overtake other xxx-particles, as well as a yyy-particle could overtake other yyy-particles without any consequences for the particles.

Like so, in a given moment of time, which we assume to be zero, a shooting of NNN xxx-particles and NNN yyy-particles starts from the two accelerators. Each particle moves with its own constant speed. The particles are numbered in the order of their shooting from 111 to NNN, this holds true for both the xxx-particles and the yyy-particles.

Remark: For time ttt, a particle with speed vvv travels distance s=v∗ts = v*ts=v∗t.

The shooting time moments for the xxx-particles are 0=tx1<tx2<tx3<....<txN0=tx_1 < tx_2 < tx_3 < .... < tx_N0=tx​1​​<tx​2​​<tx​3​​<....<tx​N​​, and their speeds are vx1,vx2,vx3,...,vxNvx_1, vx_2, vx_3, ..., vx_Nvx​1​​,vx​2​​,vx​3​​,...,vx​N​​.

Correspondingly, for the yyy-particles the moments are denoted by 0=ty1<ty2<ty3<...<tyN0=ty_1 < ty_2 < ty_3 < ... < ty_N0=ty​1​​<ty​2​​<ty​3​​<...<ty​N​​, and their speeds by vy1,vy2,vy3,...,vyNvy_1, vy_2, vy_3, ..., vy_Nvy​1​​,vy​2​​,vy​3​​,...,vy​N​​.

The shooting is executed in a way to guarantee the fulfilment of the following conditions:

Each particle will collide a particle of the opposite type;
When two particles collide, all other particles will be at a distance greater than or equal to 111 from the collision point. This is guaranteed for the first KKK collisions.
Ліміт часу 2 секунди
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
4 100 2
0 1
2 3
3 2
6 10
0 5
3 10
5 1
7 20
Вихідні дані #1
4 2
2 4