PAT (Advanced Level) 1016. Phone Bills (25)
简单模拟题。
#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 ;
}
PAT (Advanced Level) 1016. Phone Bills (25)的更多相关文章
- PTA (Advanced Level) 1016 Phone Bills
Phone Bills A long-distance telephone company charges its customers by the following rules: Making a ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT (Advanced Level) 1109. Group Photo (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
- PAT (Advanced Level) 1101. Quick Sort (25)
树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...
- PAT (Advanced Level) 1071. Speech Patterns (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1063. Set Similarity (25)
读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...
- PAT (Advanced Level) 1059. Prime Factors (25)
素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- PAT (Advanced Level) 1051. Pop Sequence (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- Linux SSH使用公钥私钥实现免登陆
公钥和私钥(我是文盲,钥字之前都是读yao,这是多音字这里应该念yue),是成对出现的,一旦任何一个做了更改都会验证失败. 1.免登陆的实现: 使用下例中ssky-keygen和ssh-copy- ...
- 前台改变asp button控件的值,后台取值没有改变的问题
前台: <asp:Button ID="btnEdit" Style="margin-left: 600px;" runat="server&q ...
- c_select 调用参数说明
c_select 调用 1. select系统调用select系统调用是用来让我们的程序监视多个文件描述符的状态变化的.程序会停在select这里等待,直到被监视的文件描述符有某一个或多个发生了状态改 ...
- ubuntu 设置vpn
百度了资料 http://jingyan.baidu.com/article/fa4125aca7f1b628ad709271.html 1. 设置 VPN CONNECTION 2.configur ...
- Oracle自增长序列
create table user_info ( id number(6) primary key, username varchar2(30) not null, password varchar2 ...
- UVA - 11732 "strcmp()" Anyone?左兄弟右儿子trie
input n 2<=n<=4000 s1 s2 ... sn 1<=len(si)<=1000 output 输出用strcmp()两两比较si,sj(i!=j)要比较的次数 ...
- AI 人工智能 探索 (四)
在写之前,先对昨天寻路插件再做一些补充,因为该插件不是很完善,所以当我发现有不能满足需求的时候,就会试图更改源代码,或增加接口来符合我的需求. 昨天补充了一条是 自身转向代码,今天补充另外一条,是及时 ...
- 2015年5月9日 student information management system
/*大作业SIMS*///头文件 #ifndef __FUNC_C__ #define __FUNC_C__ #include <stdio.h> #include <stdlib. ...
- HDU1874 最短路 SPFA
最短路 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 24 Solved: 17 [Submit][Status][Web Board] Descr ...
- 转:【WebDriver】封装GET方法来解决页面跳转不稳定的问题
在大多数测试环境中,网络或者测试服务器主机之间并不是永远不出问题的,很多时候一个客户端的一个跳转的请求会因为不稳定的网络或者偶发的其它异常hang死在那里半天不动,直到人工干预动作的出现. ...