题意:

输入24个正整数代表从0到23每个小时通话一分钟花费的美分。输入一个正整数N(<=1000),然后输入N组字符串,每个字符串包含客户的名字和通话的时刻以及打出或者挂断的状态。

按照字典序输出用户的名字,(每一段,按行输出)通话时长和花费,以及Total amount。

trick:

对于没打通的用户(没有花费),不要输出它的Total amount。(第1,2数据点答案错误原因)

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
int a[];
typedef struct users{
string name;
int month,day,hour,minute,time;
string condition;
int flag;
};
users user[];
bool cmp(users a,users b){
if(a.name!=b.name)
return a.name<b.name;
else{
if(a.day!=b.day)
return a.day<b.day;
else if(a.hour!=b.hour)
return a.hour<b.hour;
else
return a.minute<b.minute;
}
}
map<string,double>mp;
int main(){
int all=;
for(int i=;i<;++i){
cin>>a[i];
all+=a[i];
}
int n;
cin>>n;
for(int i=;i<=n;++i){
cin>>user[i].name;
scanf("%d:%d:%d:%d ",&user[i].month,&user[i].day,&user[i].hour,&user[i].minute);
cin>>user[i].condition;
if(user[i].condition[]=='n')
user[i].flag=;
}
sort(user+,user++n,cmp);
string tmp=user[].name;
user[n+].name="sewage";
for(int i=;i<=n+;++i){
if(user[i].name!=tmp&&mp[tmp])
printf("Total amount: $%.2f\n",mp[tmp]);
tmp=user[i].name;
if(user[i].flag==&&user[i+].flag==&&user[i].name==user[i+].name){
if(!mp[user[i].name]){
cout<<user[i].name;
printf(" %02d\n",user[i].month);
}
printf("%02d:%02d:%02d %02d:%02d:%02d ",user[i].day,user[i].hour,user[i].minute,user[i+].day,user[i+].hour,user[i+].minute);
double sum=;
int mm=;
mm+=-user[i].minute;
sum=1.0*(-user[i].minute)*a[user[i].hour];
mm+=user[i+].minute;
sum+=1.0*user[i+].minute*a[user[i+].hour];
user[i].hour++;
for(int j=user[i].hour;j<;++j)
sum+=1.0*a[j]*,mm+=;
for(int j=;j<user[i+].hour;++j)
sum+=1.0*a[j]*,mm+=;
mm+=(user[i+].day-user[i].day-)*;
sum+=1.0*(user[i+].day-user[i].day-)*all*;
sum/=100.0;
printf("%d $%.2f\n",mm,sum);
mp[user[i].name]+=sum;
++i;
}
}
return ;
}

【PAT甲级】1016 Phone Bills (25 分)(结构体排序)的更多相关文章

  1. PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)

    1016 Phone Bills (25 分)   A long-distance telephone company charges its customers by the following r ...

  2. PAT 甲级 1028. List Sorting (25) 【结构体排序】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1028 思路 就按照 它的三种方式 设计 comp 函数 然后快排就好了 但是 如果用 c++ ...

  3. PAT甲级1016. Phone Bills

    PAT甲级1016. Phone Bills 题意: 长途电话公司按以下规定向客户收取费用: 长途电话费用每分钟一定数量,具体取决于通话时间.当客户开始连接长途电话时,将记录时间,并且客户挂断电话时也 ...

  4. PAT 乙级 1085. PAT单位排行 (25) 【结构体排序】

    题目链接 https://www.patest.cn/contests/pat-b-practise/1085 思路 结构体排序 要注意几个点 它的加权总分 是 取其整数部分 也就是 要 向下取整 然 ...

  5. PAT A 1016. Phone Bills (25)【模拟】

    题目:https://www.patest.cn/contests/pat-a-practise/1016 思路:用结构体存储,按照名字和日期排序,然后先判断是否有效,然后输出,时间加减直接暴力即可 ...

  6. PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习

    1020 Tree Traversals (25分)   Suppose that all the keys in a binary tree are distinct positive intege ...

  7. PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)

    1146 Topological Order (25 分)   This is a problem given in the Graduate Entrance Exam in 2018: Which ...

  8. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  9. PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)

    1063 Set Similarity (25 分)   Given two sets of integers, the similarity of the sets is defined to be ...

  10. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

    1059 Prime Factors (25 分)   Given any positive integer N, you are supposed to find all of its prime ...

随机推荐

  1. vnpy源码阅读学习(5):关于MainEngine的代码阅读

    关于MainEngine的代码阅读 在入口文件中,我们看到了除了窗体界面的产生,还有关于MainEngine和EventEngin部分.今天来学习下MainEngine的代码. 首先在run代码中,我 ...

  2. vtk学习记录(一)——vtk工程配置与生成

    前言 图形图像这块儿,最近因为工作需要接触的相对多了点儿,精力基本上也都投入了这块儿,搞的天天要死要活,毕竟我一个.net的突然来到cxx的世界,也是很苦恼的,也是头一次见到新建工程就需要配置并且解决 ...

  3. AOP底层实现原理

    有两种方法实现: 当实现接口时,采用动态代理 另一种采用cglib cglib和动态代理并没有谁好谁坏,就像做菜一样,一种菜可以有多种味道,使用不同的方法就有不同的模式

  4. Go 后端主要做什么

    漫谈 Go 语言后端开发 :https://blog.csdn.net/u010986776/article/details/87276303 Golang 资深后端工程师要了解的知识:https:/ ...

  5. JAVA基础学习(6)之使用对象

    6使用对象 6.1字符类型 6.1.1字符类型 char和int互相转换 //a比A大32 Scanner in=new Scanner(System.in); char c='B'; char c1 ...

  6. collections模块、时间模块、random模块、os模块、sys模块、序列化模块、subprocess模块

    一.collections模块 1.其他数据类型 在内置数据类型(str.dict.list.tuple.set)的基础上,collections模块还提供了了几个额外的数据类型:Counter.de ...

  7. 页面布局 Paddiing Row Column Expanded 组件详解

    一.Paddiing 组件     padding    EdgeInsetss 设置填充的值     child  组件    return Padding(     padding: EdgeIn ...

  8. 我来给你讲清楚Pythony广播

    初学python广播搞的人头大,今天老师上课讲了一下,茅塞顿开,zt老师nb 首先说一下后向纬度(这个后向纬度书里边称作低维),举例:(3,4,5)后向纬度是:3*4*5或4*5或5 向量广播的条件有 ...

  9. onblur事件和onfocus事件失效

    先看onblur事件和onfocus事件的定义: <element onblur="SomeJavaScriptCode"> <element onfocus=& ...

  10. Top 9 colleges in the world from 2010 to 2020, AI and interdisciplinary areas.

    http://csrankings.org/