首页 技术 正文
技术 2022年11月12日
0 收藏 781 点赞 4,768 浏览 2552 个字

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

#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 ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898