#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int N=1010,M=31*24*60+10;
int cost[24]={0};//一天内每小时段的计费
double sum[M]={0};//从本月第一天第0分钟起以1分钟为周期的时刻的花费,这里采用了前缀表达式的想法便于计算两个合法记录间的价钱
struct record{
int minutes;//从本月第一天开始的分钟数
string state;//记录状态
string format_time;//当前时间格式
};
bool cmp(record a,record b){//比较函数
return a.minutes<b.minutes;
}
int main(){
int n;//总通话记录数
map<string,vector<record>> persons;
for(int i=0;i<24;i++){//初始化计费数组
cin>>cost[i];
}
cin>>n;
for(int i=1;i<M;i++) sum[i]=sum[i-1]+cost[(i-1)%1440/60]/100.0; //初始化sum数组
char name[20];
int month,day,hour,mintue;
char state[10],format_time[20];
for(int i=0;i<n;i++){//初始化哈希表
scanf("%s %02d:%02d:%02d:%02d %s",name,&month,&day,&hour,&mintue,state);
sprintf(format_time,"%02d:%02d:%02d",day,hour,mintue);
int minutes=(day-1)*24*60+hour*60+mintue;
persons[name].push_back({minutes,state,format_time});
}
for(auto c:persons){//遍历并进行输出
string name=c.first;
auto records=c.second;
sort(records.begin(),records.end(),cmp);
double total=0;//本月的总费用
for(int i=0;i+1<records.size();i++){
if(records[i].state=="on-line" && records[i+1].state=="off-line"){
if(!total) printf("%s %02d\n",name.c_str(),month);
cout<<records[i].format_time<<" "<<records[i+1].format_time;
double _cost=sum[records[i+1].minutes]-sum[records[i].minutes];
printf(" %d $%0.2f\n",records[i+1].minutes-records[i].minutes,_cost);
total=total+_cost;
}
}
if(total){
printf("Total amount: $%0.2f\n",total);
}
}
return 0;
}
//卧槽 太扣细节了 人都疯了md