Each athlete's skill and fatigue change linearly in time; count those who are the unique max-skill and unique min-fatigue athlete at some time t >= 0.
Hard8GeometryBinary searchSortingImplementationNo attempts yetTime limit1sMemory limit512 MBAfter the Rio Olympics a group of investors is watching N athletes of the Brazilian team. The group recorded the skill and the fatigue of every athlete at the moment the games ended, and it also found that each of the two values changes at a constant rate. Call the moment the games ended t=0.
At t=0 athlete i has skill Hi and fatigue Ci. Every unit of time the skill changes by Hit and the fatigue changes by Cit, so at time t athlete i has skill Hi+Hitt and fatigue Ci+Citt.
Athlete i is a gold athlete at time t when both conditions hold.
Neither comparison includes equality. When two or more athletes share the largest skill, or two or more share the smallest fatigue, no athlete is a gold athlete at that time. When there is only one athlete, that athlete is a gold athlete at every time.
The group invests only in gold athletes. An athlete receives an investment when there is a real time t≥0 at which the athlete is a gold athlete. t may be arbitrarily large, and an athlete who is a gold athlete at t=0 receives an investment. An athlete who was a gold athlete only at times t<0 receives nothing. Count the athletes that receive an investment.
The first line contains the number of athletes N. Line i of the next N lines contains four integers Hi, Hit, Ci, Cit separated by spaces: the skill right after the games, the rate of change of the skill, the fatigue right after the games, and the rate of change of the fatigue.
Print one line with the number of athletes that receive an investment.