Financial Risk |
In order not to displease its clients the policy of the ACME Corporation is to continue selling to a client after reaching the debt ceiling imposed by the financial insurance company. In this case the risk above the debt ceiling is assumed by the ACME Corporation.
The CEO of the ACME Corporation has to decide if the client's debt ceiling needs to be renegotiated with the financial insurance company. For that she wants to know what percentage of the client's debt is not being covered by the insurance company in the present deal.
The ACME Financial Department came up with a formula to measure a client risk. Consider the step function Dc(t) - the debt of client c at time t, as exemplified bellow.
The risk associated with a debt is the area defined by function and
the x axis, i.e. the risk between time t0 and t1 the
integral
Dc(t).
Considering that each client c has a debt ceiling Lc the
uncovered risk is just the area above the
debt ceiling that can be defined as the integral
Thus, the percentage of uncovered risk for all clients is the quotient of the sum of all uncovered risks by the sum of all risks, as given by the following formula:
Your task is to write a program to compute the percentage of uncovered risk in the last fiscal year, using the formula above and the data provided by a listing of the ACME's ERP.
The listing you will use as input starts with the number of clients with sales in the last fiscal year. For each client the first line has the debt limit and the number of sales. In the following lines, one for each sale, there is the sale's value, the day of the year of the invoice and the day of the year of the receipt.
Your program must write the percentage of uncovered risk, truncated to 2
fractional digits. Note that the output must
include the percent sign (`%').
1 2 40000 3 35000 32 61 15000 45 72 40000 97 123 55000 4 12000 10 52 30000 32 64 33000 44 73 50000 62 94
11.85%