cho.sh
Notes
Loading...

Teacher Cho Force

Time limit

2s

Memory limit

128 MB

Problem

During programming class, the students keep talking. Teacher Cho finally starts running to catch them, and the NNN noisy students start running away at the same time.

Initially, Teacher Cho is at (BX,BY)(B_X, B_Y)(BX​,BY​). Since Teacher Cho moves by vector (BVX,BVY)(BV_X, BV_Y)(BVX​,BVY​) each second, after ttt seconds the position is (BX+BVX×t,BY+BVY×t)(B_X + BV_X \times t, B_Y + BV_Y \times t)(BX​+BVX​×t,BY​+BVY​×t).

Student iii starts at (Xi,Yi)(X_i, Y_i)(Xi​,Yi​) and moves by vector (VXi,VYi)(VX_i, VY_i)(VXi​,VYi​) each second. After ttt (t≥0t \ge 0t≥0) seconds, the student's position is (Xi+VXi×t,Yi+VYi×t)(X_i + VX_i \times t, Y_i + VY_i \times t)(Xi​+VXi​×t,Yi​+VYi​×t).

At one chosen moment, Teacher Cho can catch every student inside the circle of radius RRR centered at Teacher Cho's current position. Once that chance is used, all uncaught students escape, so Teacher Cho wants to choose a time that maximizes the number of students caught at once.

Given all initial positions and movement vectors, find the maximum number of students Teacher Cho can catch in one attempt. The best time may be non-integer.

Input

The first line contains the number of students NNN, the catching radius RRR, Teacher Cho's initial position BXB_XBX​, BYB_YBY​, and Teacher Cho's movement vector BVXBV_XBVX​, BVYBV_YBVY​, separated by spaces.

Each of the next NNN lines describes one student. A line contains the student's initial position XiX_iXi​, YiY_iYi​ and movement vector VXiVX_iVXi​, VYiVY_iVYi​, separated by spaces.

Output

Print the maximum number of students Teacher Cho can catch in one attempt.

For floating-point tolerance, a student is considered catchable even when the distance between the student and Teacher Cho is within R±0.0001R \pm 0.0001R±0.0001.

Constraints

  • 1≤N≤50,0001 \le N \le 50,0001≤N≤50,000
  • 1≤R≤2,5001 \le R \le 2,5001≤R≤2,500
  • −1,000≤BX,BY≤1,000-1,000 \le B_X, B_Y \le 1,000−1,000≤BX​,BY​≤1,000
  • −100≤BVX,BVY≤100-100 \le BV_X, BV_Y \le 100−100≤BVX​,BVY​≤100
  • −1,000≤Xi,Yi,VXi,VYi≤1,000-1,000 \le X_i, Y_i, VX_i, VY_i \le 1,000−1,000≤Xi​,Yi​,VXi​,VYi​≤1,000
  • Every input value is an integer.

Hint

In the first sample, after 1.51.51.5 seconds Teacher Cho is at (0,3)(0, 3)(0,3). The students are at (0,3)(0, 3)(0,3), (−0.5,3.5)(-0.5, 3.5)(−0.5,3.5), and (4,−3.5)(4, -3.5)(4,−3.5), so students 1 and 2 are within radius 111. No time catches more students.