Given four sorted x-axis positions and a circle high above, print the index of the person the falling apple touches, or 0 for none.
Medium4GeometryMathImplementationNo attempts yetTime limit1sMemory limit32 MB
People waiting for the apple to fall.
Four people wait for an apple to fall, as in the picture. Everyone stands still at a point on the x-axis, and no two people stand at the same point. Person i (1≤i≤4) stands at the point (pi,0). A person is small compared with the coordinate plane, so ignore each person's size.

The people waiting on the x-axis.
The apple is a circle of radius r centred at the point (x,y). It hangs still in the air right now, so every point of the apple is above the x-axis, that is, in the region y>0.

The apple floating above the x-axis.
Only gravity in the −y direction acts on the apple. Gravity is constant, so the apple moves toward the ground, the x-axis, with constant acceleration, and it stops the moment it touches the x-axis.

The apple falling toward the x-axis.
The people wait for the apple, but none of them wants to be hit, so they want to know who collides with it. Given the positions of the people and the centre and radius of the apple, write a program that decides whether anyone collides with the apple, and if so, who.
The first line contains four integers p1, p2, p3, p4 (−109≤p1<p2<p3<p4≤109), separated by spaces, giving the positions of the people. Person i (1≤i≤4) stands at (pi,0).
The second line contains three integers x, y, r (−109≤x≤109, 0<y≤109, 1≤r≤109), separated by spaces, describing the apple. Its centre is the point (x,y) and its radius is r. The apple is guaranteed to float above the x-axis, that is, y>r.
Print the number of the person who collides with the apple on the first line. If nobody collides with it, print 0 instead.