简单模拟题。

#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)的更多相关文章

  1. PTA (Advanced Level) 1016 Phone Bills

    Phone Bills A long-distance telephone company charges its customers by the following rules: Making a ...

  2. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  3. PAT (Advanced Level) 1109. Group Photo (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  4. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  5. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  6. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  7. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

  8. PAT (Advanced Level) 1059. Prime Factors (25)

    素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

  9. PAT (Advanced Level) 1051. Pop Sequence (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. Spring Security-用户密码自定义加密

    public class SunPasswordEncoder implements PasswordEncoder{ //@实现加密的方法,既将明文转换为密文的方法 public String en ...

  2. overlay

    http://dockone.io/article/237 http://blog.cloud66.com/docker-with-overlayfs-first-impression/ http:/ ...

  3. 将decimal类型的数据转成2.12这样价钱的显示方式

    UnitPrice = string.Format("{0:.00}", m.UnitPrice),

  4. ant android打包--学习第一弹

    1. 准备工作 用eclipse创建一个android项目 安装ant和SDK,并且添加到系统环境变量 2.ant 使用 2.1 ant简单的帮助命令 ant -p 2.2 创建ant配置文件%AND ...

  5. CGRect相关工具函数

    NSStringFromCGRect(aCGRect): CGRectFromString(aString):如果把视图的框架以字符串的形式放在NSUserDefaults里面,那么该方法可以将其转回 ...

  6. POJ3264/RMQ

    题目链接 /* 询问一段区间内的元素差值最大是多少,用RMQ维护一个最大值和一个最小值,相减即可. */ #include<cstdio> #include<cstring> ...

  7. AutoTile 自动拼接(五) 学习与实践

    今天不讲 权值检索,考虑到后期 自动拼接 做出来 更好玩,操作更方便.所以 今天我 补充一节, 网格计算与操作. 具体就是这么个效果,和地图编辑器一样,不过图块还是没有自然的拼接,这个一定一定是 下一 ...

  8. 2015年4月27日---C语言:输出特殊图案,请在c环境中运行,看一看,Very Beautiful!

    ---恢复内容开始--- 题目:输出特殊图案,请在c环境中运行,看一看,Very Beautiful! 1.程序分析:字符共有256个.不同字符,图形不一样. 2.程序源代码: [code=c] #i ...

  9. 初探JavaScript魅力

    <style> #div1{width:200px; height:200px; background:red;} </style> </head> <scr ...

  10. acm课程练习2--1013(同1014)

    题目描述 There is a strange lift.The lift can stop can at every floor as you want, and there is a number ...