题意:
输入两个正整数N和K(N<=1e4,K<=8e4),接着输入N行数据每行包括三个字符串表示车牌号,当前时间,进入或离开的状态。接着输入K次询问,输出当下停留在学校里的车辆数量。最后一行输出总计停留时间最长的车牌号(字典序升序输出)和停留总时。

AAAAAccepted code:

//因为一天只有86400秒,所以可以用一个car数组在统计车辆停留时间时在进入时间+1,离开时间-1。再用一个sum数组扫一遍,sum[i]=sum[i-1]+car[i],即可表示当下时间有多少辆车还在停留在校园内。

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
vector<pair<string,int> >v[];
int sum[],car[];
int t[];
map<int,string>id;
vector<string>name;
int a[];
void clear(string&s){
string ss;
swap(s,ss);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
int cnt=;
for(int i=;i<=n;++i){
string s;
cin>>s;
string t;
cin>>t;
string f;
cin>>f;
if(!mp[s])
mp[s]=++cnt;
id[mp[s]]=s;
int flag=;
if(f[]=='i')
flag=;
v[mp[s]].push_back({t,flag});
}
for(int i=;i<=cnt;++i){
sort(v[i].begin(),v[i].end());
string now;
int flag=;
for(int j=;j<v[i].size();++j){
if(v[i][j].second==){
now=v[i][j].first;
flag=;
}
else{
if(flag){
string tamp=v[i][j].first;
int start=(now[]-'')*+(now[]-'')*+(now[]-'')*+(now[]-'')*+(now[]-'')*+(now[]-'');
int over=(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'');
++car[start];
--car[over];
flag=;
clear(now);
t[i]+=over-start;
}
}
}
}
sum[]+=car[];
for(int i=;i<;++i)
sum[i]=sum[i-]+car[i];
for(int i=;i<=k;++i){
string tamp;
cin>>tamp;
int tt=(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'')*+(tamp[]-'');
cout<<sum[tt]<<"\n";
}
int mx=;
for(int i=;i<=cnt;++i)
mx=max(mx,t[i]);
for(int i=;i<=cnt;++i)
if(mx==t[i])
name.push_back(id[i]);
sort(name.begin(),name.end());
for(int i=;i<name.size();++i)
cout<<name[i]<<" ";
a[]=mx/;
mx%=;
a[]=mx/;
mx%=;
a[]=mx/;
mx%=;
a[]=mx/;
mx%=;
a[]=mx/;
mx%=;
a[]=mx;
cout<<a[]<<a[]<<":"<<a[]<<a[]<<":"<<a[]<<a[];
return ;
}

【PAT甲级】1095 Cars on Campus (30 分)的更多相关文章

  1. PAT甲级1095. Cars on Campus

    PAT甲级1095. Cars on Campus 题意: 浙江大学有6个校区和很多门.从每个门口,我们可以收集穿过大门的汽车的进/出时间和车牌号码.现在有了所有的信息,你应该在任何特定的时间点告诉在 ...

  2. PAT甲级——1095 Cars on Campus (排序、映射、字符串操作、题意理解)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93135047 1095 Cars on Campus (30 分 ...

  3. PAT甲级——1131 Subway Map (30 分)

    可以转到我的CSDN查看同样的文章https://blog.csdn.net/weixin_44385565/article/details/89003683 1131 Subway Map (30  ...

  4. PAT 甲级 1076 Forwards on Weibo (30分)(bfs较简单)

    1076 Forwards on Weibo (30分)   Weibo is known as the Chinese version of Twitter. One user on Weibo m ...

  5. PAT 甲级 1068 Find More Coins (30 分) (dp,01背包问题记录最佳选择方案)***

    1068 Find More Coins (30 分)   Eva loves to collect coins from all over the universe, including some ...

  6. PAT 甲级 1045 Favorite Color Stripe (30 分)(思维dp,最长有序子序列)

    1045 Favorite Color Stripe (30 分)   Eva is trying to make her own color stripe out of a given one. S ...

  7. PAT 甲级 1018 Public Bike Management (30 分)(dijstra+dfs,dfs记录路径,做了两天)

    1018 Public Bike Management (30 分)   There is a public bike service in Hangzhou City which provides ...

  8. PAT 甲级 1014 Waiting in Line (30 分)(queue的使用,模拟题,有个大坑)

    1014 Waiting in Line (30 分)   Suppose a bank has N windows open for service. There is a yellow line ...

  9. PAT (Advanced Level) Practise - 1095. Cars on Campus (30)

    http://www.patest.cn/contests/pat-a-practise/1095 Zhejiang University has 6 campuses and a lot of ga ...

随机推荐

  1. Tomcat 端口配置,及原理详解

    1 tomcat 文件配置详细说明 tomcat服务器需配置三个端口才能启动,安装时默认启用了这三个端口,当要运行多个tomcat服务时需要修改这三个端口,不能相同.端口配置路径为tomcat\ co ...

  2. 查看和设置mysql字符集

    http://218.194.248.2/~wuxiaogang/cpcourse/database/mysql/charset.htm 1. 修改mysql的my.cnf# vi /etc/my.c ...

  3. chrome firefox浏览器屏蔽百度热搜

    我是原文 操作 点击拦截元素,然后选择页面元素,添加

  4. SaltStack自动化软件简介及安装

    ==================================================================================================== ...

  5. APL: ANSYS Power Library

    1. creating accurate switching current waveforms (profiles) 2.output-state dependent decoupling capa ...

  6. thinkphp 接收文件并处理

    html前台文件,上传到控制器,thinkphp处理它 前台 <form action="{:url('product/brand_addcl')}" enctype=&qu ...

  7. web开发一些资源的在线引用地址

    <!-- Bootstrap --> <link rel="stylesheet" href="https://cdn.bootcss.com/boot ...

  8. split()函数+merge()函数

    在图像处理时,我们接触到的彩色以RGB居多,为了分析图像在某一通道上的特性,需要将图像的颜色通道进行分离,或者是在对某一颜色通道处理后重新进行融合.opencv提供了split()函数来进行颜色通道的 ...

  9. Angular 2.0 文本拖拽

    基于Angular7.1和TypeScript实现 Html代码 <div style="padding-left: 0px;"> <div id='conten ...

  10. EVE-NG镜像模板资源占用统计

    转:http://www.emulatedlab.com/forum.php?mod=viewthread&tid=432&extra=page%3D1 EVE  Image fold ...