Dynamo Wheel

단위 원형 물레방아의 양동이가 꼭대기에서 채워지고 바닥에서 비워질 때, 모든 회전 각도에서 무게중심의 최대 x성분을 구한다.

어려움8수학기하이분 탐색누적 합아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

A water wheel is a device for converting the potential energy of water into the kinetic energy of rotation. We have attached buckets along our otherwise perfectly-balanced wheel. Each bucket has a specific weight when empty, and a specific weight when full of water, both in kilograms.

Whenever a bucket reaches the top of the water wheel, it is filled to its maximum capacity. When the bucket reaches the bottom, diametrically opposite, it is emptied again.

Figure D.1: Illustration of Sample Input 1 at approximately 15.0 degrees clockwise from the start. The centre of mass is drawn as a vector from the origin.

The acceleration of the wheel depends on the horizontal distance between the centre of mass of the wheel and its axis of rotation. Centre of mass of the wheel at some time is defined as the sum of the co-ordinates of the buckets at that time multiplied by their weight.

Our water wheel has a radius of exactly 1 metre. What is the maximum positive x-component of centre of mass achieved by the wheel at any angle?

입력

  • The first line of input contains the number of buckets on the wheel, n (2 ≤ n ≤ 105).

  • The remaining n lines of input each contain a description of a bucket, in angular order:

    • the decimal clockwise angle of the ith bucket in degrees, di (0.0 ≤ d ≤ 360.0),
    • the decimal weights of this bucket when empty and full, ei and fi (0 ≤ ei ≤ fi ≤ 104).

출력

Output the maximum horizontal component of the centre of mass of the wheel over all possible angles. Your answer should be within an absolute or relative error of at most 10−6.