AC代码:
[cpp]
//1016 13:00
#include
#include
#include
using namespace std;
const int NUM=1005;
struct record
{
string name;
int dd,hh,mm;
string status;
int total;
}rec[NUM];
struct call
{
int s;
int e;
double m;
}cal[NUM];
int toll[26];
int sumToll;
int cmp(const void *a, const void *b)
{
record *x=(record *)a;
record *y=(record *)b;
// if(x->name==y->name&&x->dd==y->dd&&x->hh==y->hh)
// return x->mm - y->mm;
// if(x->name==y->name&&x->dd==y->dd)
// return x->hh - y->hh;
// if(x->name==y->name)
// return x->dd - y->dd;
// return x->name < y->name;
if(x->name==y->name)
return x->total - y->total;
if(x->name < y->name)
return -1;
else return 1;
}
int find(int start,int end)
{
int ans=0,i;
if(rec[start].dd
for(i=rec[start].hh+1;i<24;i++){
ans+=toll[i]*60;
}
for(i=0;i
ans+=toll[i]*60;
ans+=(60-rec[start].mm)*toll[rec[start].hh];
ans+=rec[end].mm*toll[rec[end].hh];
ans+=(rec[end].dd-rec[start].dd-1)*sumToll*60;
} else if(rec[start].dd==rec[end].dd) {
if(rec[end].hh>rec[start].hh){
for(i=rec[start].hh+1;i
ans+=toll[i]*60;
ans+=(60-rec[start].mm)*toll[rec[start].hh];
ans+=rec[end].mm*toll[rec[end].hh];
} else {
ans+=(rec[end].mm-rec[start].mm)*toll[rec[end].hh];
}
} else
ans=-1;
return ans;
}
int main()
{
int n,i,j,month;
freopen("C:\\Documents and Settings\\Administrator\\桌面\\input.txt","r",stdin);
sumToll=0;
for(i=0;i<24;i++){
cin>>toll[i];
sumToll+=toll[i];
}
cin>>n;
for(i=0;i
//cin>>rec[i].name>>month>>":">>rec[i].dd>>":">>rec[i].hh>>":">>rec[i].mm>>rec[i].status;
cin>>rec[i].name;
cin>>month;
getchar();
cin>>rec[i].dd;
getchar();
cin>>rec[i].hh;
getchar();
cin>>rec[i].mm;
cin>>rec[i].status;
rec[i].total=rec[i].dd*60*24+rec[i].hh*60+rec[i].mm;
}
qsort(rec,n,sizeof(rec[0]),cmp);
string str="";
int start,end,flag=0;
int theSame=0;
rec[n].name="";
double money=0.0f;
int minute;
double sum=0.0f;
int index=0;