| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10327 | Lab10 |
|
Description
This problem deals with deposit (D) and withdrawal (W) of bank accounts. We have known that several users may share a single account. You will be indicated if a user shares a same account with another user. Then you will be asked to perform several account deposit or withdrawal, and calculate the average account balance.
For instance, an input line 1 2 represents that users 1 and 2 share with the same account. Users 1 and 2 can deposit or withdraw the money in their shared account. If the account has 0 dollars originally, an input line 1 D 60 represents that user 1 deposits 60 dollars and 2 W 20 represents that user 2 withdraws 20 dollars to/from their shared account. In the end, there are 40 dollars and 2 users with the same account. Thus, the average money of their account is 40/2=20.00 dollars.
Note:
(1) Suppose we have 100 members at most.
(2) Each account has 0 dollars in the beginning.
(3) For a withdrawal operation, if the account balance is smaller than the amount of money to be withdrawn, this operation should be ignored.
Input
M
Users a1 and b1 share a same account
Users a2 and b2 share a same account
…
Users aM and bM share a same account
N
Account operation 1 (User / Deposit (D) or Withdraw (W) / Money)
Account operation 2 (User / Deposit (D) or Withdraw (W) / Money)
…
Account operation N (User / Deposit (D) or Withdraw (W) / Money)
P
User_ID1 User_ID2 … User_IDP
Output
Calculate the corresponding average account balance of the asked P users (User_ID1, User_ID2, … , User_IDP).
Each answer is printed using the format “%.2f\n”.