英文描述
Phone Bills (25)
A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month, given a set of phone call records.
Input Specification:
Each input file contains one test case. Each case has two parts: the rate structure, and the phone call records.The rate structure consists of a line with 24 non-negative integers denoting the toll (cents/minute) from 00:00 - 01:00, the toll from 01:00 - 02:00, and so on for each hour in the day.The next line contains a positive number N (<= 1000), followed by N lines of records. Each phone call record consists of the name of the customer (string of up to 20 characters without space), the time and date (mm:dd:hh:mm), and the word “on-line” or “off-line”.For each test case, all dates will be within a single month. Each “on-line” record is paired with the chronologically next record for the same customer provided it is an “off-line” record. Any “on-line” records that are not paired with an “off-line” record are ignored, as are “off-line” records not paired with an “on-line” record. It is guaranteed that at least one call is well paired in the input. You may assume that no two records for the same customer have the same time. Times are recorded using a 24-hour clock.
Output Specification:
For each test case, you must print a phone bill for each customer.
Bills must be printed in alphabetical order of customers’ names. For each customer, first print in a line the name of the customer and the month of the bill in the format shown by the sample. Then for each time period of a call, print in one line the beginning and ending time and date (dd:hh:mm), the lasting time (in minute) and the charge of the call. The calls must be listed in chronological order. Finally, print the total charge for the month in the format shown by the sample.
Sample Input:
10 10 10 10 10 10 20 20 20 15 15 15 15 15 15 15 20 30 20 15 15 10 10 10
10
CYLL 01:01:06:01 on-line
CYLL 01:28:16:05 off-line
CYJJ 01:01:07:00 off-line
CYLL 01:01:08:03 off-line
CYJJ 01:01:05:59 on-line
aaa 01:01:01:03 on-line
aaa 01:02:00:01 on-line
CYLL 01:28:15:41 on-line
aaa 01:05:02:24 on-line
aaa 01:04:23:59 off-line
Sample Output:
CYJJ 01
01:05:59 01:07:00 61 $12.10
Total amount: $12.10
CYLL 01
01:06:01 01:08:03 122 $24.40
28:15:41 28:16:05 24 $3.85
Total amount: $28.25
aaa 01
02:00:01 04:23:59 4318 $638.80
Total amount: $638.80
中文描述
电话账单
一个长途电话公司的收费规则如下:一个长途电话的消费是根据每分钟的价钱来定计算的,这价钱依赖于一天中的不同时段。当一个顾客开始打电话的时候,这个时间会被电话公司记录,当顾客挂断电话时,这个时间也会被记录。每个月,带有每段通话记录的账单将会发送给客户,其中每段通话是根据一天中不同时间段来计算的。你的工作是准备每月的账单和手机通话记录的一个集合。
输入规则:
每个输入文件包含一个测试用例。每个用例有两个部分:比率结构体和手机通话记录。比率结构体是指在一行内有24个非负数的整数,这24个整数代表着长途电话费。第一个数字代表从00:00到01:00的电话费,第二个数字代表从01:00到02:00的电话费,依次类推。第24个数字就代表着23:00到00:00的电话费。这个包含关系好像没有说清楚,比如一个人从00:30开始打电话,打到了01:22。那么我想问其中的01:00算第一个数字的费用还是算第二个数字的费用?下一行包含一个正数N(<= 1000),接着是N条记录。每条记录包含一个顾客的名字(由20个字符组成不包含空格),一个时间和日期(mm:dd:hh:mm),一个单词:在线或者下线。每个测试用例,所有的数据都在一个月中。每个在线记录和下线记录是按照时间先后顺序成对出现的。任何一个没有对应下线记录的在线记录都将被忽略,任何一个没有对应在线记录的下线记录也会被忽略。输入保证至少有一对在线记录和下线记录是对应的。你可以假设在同一时间没有任何两条记录是相同的。时间采用24小时制。
输出规则:
对于每个测试用例,你必须每个顾客的手机账单。打印账单必须按照顾客名字的字母顺序进行打印(大写在小写)。对于每个顾客,在第一行内输出顾客名字和月份,格式如输出样例。之后打印每个时间段的电话,在一行内打印开始和结束时间和日期(dd:hh:mm),最后打印时间(分钟)和收费。没通电话必须按照时间先后顺序排序(这里默认为通话时长的递减顺序)。最后一行打印每月的总收费,格式如样例输出。
样例输入:
10 10 10 10 10 10 20 20 20 15 15 15 15 15 15 15 20 30 20 15 15 10 10 10
10
CYLL 01:01:06:01 on-line
CYLL 01:28:16:05 off-line
CYJJ 01:01:07:00 off-line
CYLL 01:01:08:03 off-line
CYJJ 01:01:05:59 on-line
aaa 01:01:01:03 on-line
aaa 01:02:00:01 on-line
CYLL 01:28:15:41 on-line
aaa 01:05:02:24 on-line
aaa 01:04:23:59 off-line
样例输出:
CYJJ 01
01:05:59 01:07:00 61 $12.10
Total amount: $12.10
CYLL 01
01:06:01 01:08:03 122 $24.40
28:15:41 28:16:05 24 $3.85
Total amount: $28.25
aaa 01
02:00:01 04:23:59 4318 $638.80
Total amount: $638.80