简单模拟题。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
using namespace std; int cost[];
int n;
struct X
{
string name;
int dd,hh,mm,len,f;
}s[],ans[];
int month;
bool flag[]; bool cmp(const X&a,const X&b)
{
if(a.len==b.len) return a.f>b.f;
return a.len<b.len;
} bool cmp2(const X&a,const X&b)
{
if(a.name==b.name) return a.len<b.len;
return a.name<b.name;
} int get(int a,int b)
{
int sum=; for(int i=ans[a].len;i<ans[b].len;i++)
{
int DD=i/(*);
int HH=(i-DD**)/;
sum=sum+cost[HH];
}
return sum;
} int main()
{
for(int i=;i<;i++) scanf("%d",&cost[i]);
scanf("%d",&n);
for(int i=;i<=n;i++)
{
cin>>s[i].name;
scanf("%d:%d:%d:%d",&month,&s[i].dd,&s[i].hh,&s[i].mm);
s[i].len=s[i].dd**+s[i].hh*+s[i].mm;
char op[]; scanf("%s",op);
if(op[]=='n') s[i].f=;
else s[i].f=;
}
memset(flag,,sizeof flag); sort(s+,s++n,cmp);
int tot=;
for(int i=;i<=n;i++)
{
if(flag[i]==) continue;
if(s[i].f==) continue;
for(int j=i+;j<=n;j++)
{ if(s[i].name==s[j].name)
{
if(s[j].f==&&flag[j]==){
ans[++tot]=s[i];
ans[++tot]=s[j];
flag[i]=; flag[j]=;
}
break;
}
}
} sort(ans+,ans++tot,cmp2); int pos=;
cout<<ans[].name<<" "; printf("%02d\n",month);
printf("%02d:%02d:%02d ",ans[pos].dd,ans[pos].hh,ans[pos].mm);
printf("%02d:%02d:%02d ",ans[pos+].dd,ans[pos+].hh,ans[pos+].mm);
printf("%d ",ans[pos+].len-ans[pos].len);
printf("$%.2lf\n",1.0*get(,)/); double sum=1.0*get(,)/; pos=pos+; for(int i=pos;i<=tot;i=i+)
{
if(ans[i].name==ans[i-].name)
{
printf("%02d:%02d:%02d ",ans[i].dd,ans[i].hh,ans[i].mm);
printf("%02d:%02d:%02d ",ans[i+].dd,ans[i+].hh,ans[i+].mm);
printf("%d ",ans[i+].len-ans[i].len);
printf("$%.2lf\n",1.0*get(i,i+)/);
sum=sum+1.0*get(i,i+)/;
}
else
{
printf("Total amount: $%.2lf\n",sum);
cout<<ans[i].name<<" "; printf("%02d\n",month);
printf("%02d:%02d:%02d ",ans[i].dd,ans[i].hh,ans[i].mm);
printf("%02d:%02d:%02d ",ans[i+].dd,ans[i+].hh,ans[i+].mm);
printf("%d ",ans[i+].len-ans[i].len);
printf("$%.2lf\n",1.0*get(i,i+)/);
sum=1.0*get(i,i+)/;
}
}
printf("Total amount: $%.2lf\n",sum);
return ;
}