|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||5||2||2||66.667%|
From time to time, customers of the First Goldfields Bank of Pembroke make dramatic errors with their banking transactions. For example, they might add an extra zero and transfer \$10,000 to someone else when they only intended to transfer \$1,000. The bank theorises that this is related to the large sums of money and large drinking budgets associated with a successful goldfield, and plans to introduce transaction limits to detect and prevent serious errors.
Each transaction is a request to transfer an amount of money from one account to another. There are two different kinds of transactions: if the transfer is between two accounts owned by the same customer, then it is an inter-account transfer (IAT); otherwise, when transferring money to someone else’s account, the transaction is known as a payment.
The bank has invited each customer to specify a maximum instruction limit and a daily exposure limit for each kind of transaction, with the expectation that most customers will want to set higher limits for inter-account transfers than for general payments.
These limits are applied as follows:
Your task is to write the program to enforce these limits.
Each line of the input file is a banking record, consisting of a number of fields separated by commas (‘,’). There are four types of banking record, distinguished by the first field:
All amounts in the input data are dollars and cents values written with a decimal point (‘.’) and two cents digits (but no commas), with a maximum value of \$9,999,999.99. All ‘1’ records appear before all ‘2’ records, which appear before all ‘5’ records, which appear before the ‘9’ record.
All customer names appearing in ‘2’ or ‘5’ records will be valid customers who have been listed in exactly one ‘1’ record, and all account numbers appearing in ‘5’ records will be valid accounts which have been listed in exactly one ‘2’ record. Furthermore, the ‘5’ records will appear in increasing datestamp order. There will be no more than 50 customers and 200 accounts.
The bank does not accept transactions between 23:00 and 06:00, believing that customers will be more than usually impaired during these periods—especially at weekends. Hence such times do not appear in the input file.
Output must contain one line for each input ‘5’ record, starting with ‘INSTRUCTION n: ’, where n is the instruction number (starting from 1), followed by one of the following messages, as appropriate:
‘NOT OWNER’ if the source account is not owned by the customer;
‘IAT MAX EXCEEDED’ or ‘PAYMENT MAX EXCEEDED’ if the transaction amount exceeds the applicable maximum instruction limit;
‘IAT DEL EXCEEDED’ or ‘PAYMENT DEL EXCEEDED’ if the transaction amount would cause the applicable daily exposure limit to be exceeded;
or ‘IAT OK’ or ‘PAYMENT OK’ if the transaction is successful.
If a transaction fails both limit tests, output only the ‘. . . MAX EXCEEDED’ message.
1,ROARIMEG,10000.00,20000.00,5000.00,5000.00 1,ASPINALL,1000000.00,5000000.00,250000.00,1000000.00 2,ROARIMEG,123456 2,ROARIMEG,123457 2,ASPINALL,246800 2,ASPINALL,246801 5,20060729101537,ROARIMEG,123456,1000.00,246800 5,20060729111600,ASPINALL,246800,2000000.00,246801 5,20060729151537,ROARIMEG,123457,4500.00,246801 5,20060730084813,ROARIMEG,123457,4500.00,246801 9
INSTRUCTION 1: PAYMENT OK INSTRUCTION 2: IAT MAX EXCEEDED INSTRUCTION 3: PAYMENT DEL EXCEEDED INSTRUCTION 4: PAYMENT OK