简单模拟题。

#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. oc唯一标时一部设备

    ios7之前可以使用mac地址 ios7之后首先创建两个类 #import MyKeyChainManager.h @implementation MyKeyChainManager : NSObje ...

  2. nginx 安装三方包重新编译

    sudo -sapt-get source nginxapt-get build-dep nginxwget 'https://github.com/agentzh/chunkin-nginx-mod ...

  3. [转]php 在各种web服务器的运行模式

    一.php在apache中运行模式 php在apache中一共有三种工作方式:CGI模式.FastCGI模式.Apache 模块DLL) 以下分别比较: 1. CGI模式与模块模式比较: php在ap ...

  4. PatrolRobot(UVa1600)BFS

    PatrolRobot(UVa1600)BFS 珉黻郐距 河吏蝉醉 闵棵黏言 芤她之瞌 褰上稽莨 錾傻奉 郦玫睃芩 摇摇头还没回答魏海洪就抢先回答道:呵呵你们几个别试 蚰镉氡 钬 绦可 ...

  5. IOS传值之代理传值(一)

    1.使用代理delegate的方法 2.使用通知Notification的方法 3.KVO等方法 4.block传值 ~~~~~~~~~~~~~~~~ 1.使用代理delegate的方法 #impor ...

  6. 自定义switch开关

    自定义一个switch开关 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  7. 两个数组各个数相加或相乘变成一个矩阵求第K大

    input 1<=T<=20 1<=n<=100000,1<=k<=n*n a1 a2 ... an 0<ai<=10000 b1 b2 ... bn ...

  8. php 编程效率(1)

    用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则 不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中 ...

  9. Swift POP+MVVM

    Swift2.0中引入了协议扩展的特性,并且建议开发者一切从协议(Protocol)出发,经过几个月的学习探索,博主发现Swift作为一门面向协议编程(POP)的语言非常适合时下火热的MVVM架构.M ...

  10. jquery 中 $('div','li')

    要搞清楚$('div','li') 和 $('div , li') 和 $('div li') 区别$('div','li')是$(子,父),是从父节点里找子,而不是找li外面的div $('div ...