这题写得头晕……明天我再评价

#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <map> #define I scanf
#define OL puts
#define O printf
#define F(a,b,c) for(a=b;a<c;a++)
#define FF(a,b) for(a=0;a<b;a++)
#define FG(a,b) for(a=b-1;a>=0;a--)
#define LEN 1010
#define MAX 0x06FFFFFF
#define V vector<int> using namespace std; set<string> printTitle; typedef struct Record{
string name;
int month,dd,hh,mm;
int isOn;
Record(){}
Record(const Record& o){
name=o.name;month=o.month;dd=o.dd;hh=o.hh;mm=o.mm;isOn=o.isOn;
}
}Record; Record info[LEN];
int rate[];
int one_day_bill=; void init_one_day_bill(){
int i;
FF(i,){
one_day_bill+=*rate[i];
}
} bool cmp(Record a,Record b){
/*
if(a.name<b.name) return true;
else if(a.mouth<b.mouth) return true;
else if(a.dd<b.dd) return true;
else if(a.hh<b.hh) return true;
else if(a.mm<b.mm) return true;
return false;*/
if(a.name!=b.name) return a.name<b.name;
else if(a.month!=b.month) return a.month<b.month;
else if(a.dd!=b.dd) return a.dd<b.dd;
else if(a.hh!=b.hh) return a.hh<b.hh;
else return a.mm<b.mm;
} void diff(Record a,Record b,int& minute,int& money){
// minute=b.mm-a.mm+(b.hh-a.hh)*60+(b.dd-a.dd)*24*60;
// int i;
// money=0;
// if(a.dd!=b.dd)
// money+=(b.dd-a.dd)*one_day_bill;
// if(a.hh==b.hh) money=minute*rate[a.hh];
// else{
// for(i=a.hh;i<=b.hh;i++){
// if(i==a.hh) money+=(60-a.mm)*rate[i];
// else if(i==b.hh) money+=(b.mm)*rate[i];
// else money+=(60)*rate[i];
// }
// }
Record tmp=a;
minute=;money=;
while(tmp.dd<b.dd || tmp.hh< b.hh || tmp.mm < b.mm){
minute++;
money+=rate[tmp.hh];
tmp.mm++;
if(tmp.mm>=){
tmp.mm=;
tmp.hh++;
}
if(tmp.hh>=){
tmp.hh=;
tmp.dd++;
}
}
} int main(){
freopen("d:/input/A1016.txt","r",stdin);
int n,i;
FF(i,){
scanf("%d",&rate[i]);
}
init_one_day_bill();
scanf("%d",&n);
FF(i,n){
char buffer[];
I("%s",buffer);
I("%d:%d:%d:%d",&info[i].month,&info[i].dd,&info[i].hh,&info[i].mm);
info[i].name=buffer;
I("%s",buffer);
if(string(buffer)=="on-line") info[i].isOn=;
else info[i].isOn=;
}
sort(info,info+n,cmp); int on=,off,next;
while(on<n){
int needPrint=;
next=on;
while(next<n && info[next].name==info[on].name){
if(needPrint== && info[next].isOn){
needPrint=;
}else if(needPrint== && info[next].isOn==){
needPrint=;
}
next++;
}
// printf("%d\n",needPrint);
if(needPrint<){
on=next;
continue;
}
int allMoney=;
O("%s %02d\n",info[on].name.c_str(),info[on].month);
while(on<next){
while(on<next- && !(info[on].isOn&&info[on+].isOn==)) on++;
off=on+;
if(off==next){
on=next;
break;
}
Record a=info[on],b=info[off];
int minute;
int money;
diff(a,b,minute,money);
allMoney+=money;
O("%02d:%02d:%02d %02d:%02d:%02d %d $%.2lf\n",a.dd,a.hh,a.mm,b.dd,b.hh,b.mm,minute,money/.);
on=off+;
}
O("Total amount: $%.2lf\n",allMoney/.);
}
return ;
}
05-25 22:14