国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

1016. Phone Bills (25)-難

2019-11-08 18:25:55
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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.10Totalamount:12.10 CYLL 01 01:06:01 01:08:03 122 24.4028:15:4128:16:05243.85 Total amount: 28.25aaa0102:00:0104:23:594318638.80 Total amount: $638.80

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=1010;struct Record{ char name[30],time[20],state[10];}rec[maxn],valid[maxn];int toll[24];bool cmp(Record a,Record b){ int n=strcmp(a.name,b.name); int t=strcmp(a.time,b.time); if(n!=0) return n<0; else return t<0; }void getTimeAndM(char a[],char b[],int& time,double& money){ int d1,h1,m1,d2,h2,m2; sscanf(a,"%d:%d:%d",&d1,&h1,&m1); sscanf(b,"%d:%d:%d",&d2,&h2,&m2); while(d1<d2||h1<h2||m1<m2){ time++; money+=toll[h1]; m1++; if(m1>=60){ m1=0; h1++; } if(h1>=24){ h1=0; d1++; } }}int main(){ int n; for(int i=0;i<24;i++){ scanf("%d",&toll[i]); } scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%s %s %s",rec[i].name,rec[i].time,rec[i].state); } sort(rec,rec+n,cmp); int cnt=0; for(int i=0;i<n;i++){ if(strcmp(rec[i].name,rec[i+1].name)==0&&rec[i].state[1]=='n'&&rec[i+1].state[1]=='f'){ valid[cnt++]=rec[i]; valid[cnt++]=rec[i+1]; } }// printf("有效的:/n");// for(int i=0;i<cnt;i++){// printf("%s %s %s/n",valid[i].name,valid[i].time,valid[i].state);// } char month[10]; month[0]=valid[0].time[0];month[1]=valid[0].time[1];month[2]='/0'; int first=0; while(first<cnt){ int next=first;//next指向下一個(gè)客戶(hù) while(next<cnt&&strcmp(valid[first].name,valid[next].name)==0){ next++; } printf("%s %s/n",valid[first].name,month); double total=0; int i=first; while(i<next){ printf("%s %s",valid[i].time+3,valid[i+1].time+3); int time=0; double money=0; getTimeAndM(valid[i].time+3,valid[i+1].time+3,time,money); total+=money; printf(" %d $%.2f/n",time,money/100); i+=2; } printf("Total amount: $%.2f/n",total/100); first=next; } return 0; }
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 监利县| 体育| 德格县| 万安县| 梁河县| 仲巴县| 白朗县| 潜山县| 竹山县| 增城市| 嘉祥县| 莒南县| 阿尔山市| 宁远县| 乌拉特前旗| 岳阳市| 卢氏县| 左权县| 双牌县| 竹北市| 罗平县| 河池市| 肥乡县| 民县| 玉龙| 本溪| 盐城市| 盈江县| 巨野县| 密山市| 西盟| 巴东县| 常山县| 贵阳市| 梅州市| 加查县| 南汇区| 盱眙县| 苏州市| 阿荣旗| 称多县|