ZOJ Problem Set - 3565
The capital stock (or just stock) of a business entity represents the original capital paid into or invested in the business by its founders. It serves as a security for the creditors of a business since it cannot be withdrawn to the detriment of the creditors. Stock is distinct from the property and the assets of a business which may fluctuate in quantity and value.
Call auction is one effective way to determine the opening price. There are a lot of technical terms and rules. But in this problem, you only need to know the rules as follows:
SXSTAR has bought a stock, 000876, New Hope. Its opening price increased by 10% on 5th July, 2011, but he didn't sell it out because he didn't know much about the call auction. So SXSTAR turns to you to help him to calculate the opening price and volume of one stock.
There are several test cases (<=100). You should process to the end of input. For each test case, the first line has one integers N (0 <= N <= 100000). Then followed by N lines. Each line has 3 numbers. The first one is an integer, which means the quotation type, 1 is for selling and 2 is for buying. The second one is a positive real number (<= 1000000), which means the price of quotation. The third one is a non-negative integer (<= 1000000), which means the shares.
For each case, you should print a single line with the opening price and volume, two numbers should be separated by a space. Your answer of opening price should round to two decimal places. If there is no opening price, print "null" instead of opening price.
2 1 100.05 100 2 100.05 100
Author: SHEN, Xin
Contest: ZOJ Monthly, December 2011