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中设置共享目录
1. 是否安装了samba服务 sudo apt-get install samba sudo apt-get install smbfs 2. 创建需要共享的目录/ home/usr/share ...
- Replication--进程无法在“xxxx”上执行“sp_replcmds”
错误消息:进程无法在“xxxx”上执行“sp_replcmds”. (源: MSSQL_REPL,错误号: MSSQL_REPL20011)获取帮助: http://help/MSSQL_REPL20 ...
- VMware 全虚拟打开
1.修改.vmx 文件,最后一行加入: hypervisor.cpuid.v0 = “FALSE" mce.enable = “TRUE" vhv.enable = “TRUE&q ...
- phonegap的照相机API
1. Camera Api简单介绍 2. 拍照 3. 预览照片 一. Camera Api简单介绍 Camera选择使用摄像头拍照,或从设备相册中获取一张照片.图片以base64编码的 字符串或图片U ...
- STM32F4系统时钟配置及描述
STM32F4系统时钟配置及描述 stm32f407时钟配置方法(感觉很好,分享一下) STM32F4_RCC系统时钟配置及描述 STM32F4时钟设置分析 stm32f4 - 时钟树分析配置
- cocos2d-x 不规则形状按钮的点击判定
cocos2d-x 不规则形状按钮的点击判定 原理: 1.OpeGL ES提供了glReadPixels[^footnote]函数,来获取当前framebuffer上的像素数据 2.cocos2d-x ...
- 事件委托小demo(原生版)
<style type="text/css"> body, div, span { margin:; padding:; font-family: "\5FA ...
- 3个同一行div的摆放div
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- opencv基础知识------IplImage, CvMat, Mat 的关系和相互转换
Mat,cvMat和IplImage这三种类型都可以代表和显示图像,但是,Mat类型侧重于计算,数学性较高,openCV对Mat类型的计算也进行了优化.而CvMat和IplImage类型更侧重于“图像 ...
- 转换流--InputStreamReader ,OutputStreamWriter
BufferedReader 字符流,只能装饰字符流,不能装饰字节流.有个重要且好用的方法是readLine()整行读取字符. 但是InputStream是字节流,没有resdLine方法,那么字节流 ...