题意:
输入两个正整数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. centos7下使用selenium实现文件上传

    1.pip install SendKeys 2. 利用js去掉元素的隐藏属性,然后输入: 一般控制元素显示或隐藏是用display属性来实现的 style.display = “none”,表示元素 ...

  2. SpringMVC请求乱码问题

    今天做一个项目实现插入数据的功能,最开始没有添加FilterEncoding处理字符集乱码了,那是正常的,后来我添加过之后依然还是乱码,让我 百思不得其解,代码配置如下: EncodingFilter ...

  3. 【转载】Hibernate关系映射

    1.        单向一对一关联映射(one-to-one): 两个对象之间一对的关系,例如:Person(人)-IdCard(身份证) 有两种策略可以实现一对一的关联映射: *主键关联:即让两个对 ...

  4. dp--B - Hard problem

    B - Hard problem Vasiliy is fond of solving different tasks. Today he found one he wasn't able to so ...

  5. qq自己设定动态图像视屏

    类似于样但是是自己定义的视屏先上壁纸 这个具体是怎么制作的呢? 先从网络上下载自己喜欢的mp4视屏 qq头像上面点击拍摄动态图像 先随意拍摄2秒保持拍摄完成的状态不要点击确定 然后用手机文件夹找到你要 ...

  6. MSSQL 打开xp_cmdshell

    sp_configure reconfigure go sp_configure reconfigure go

  7. AcWing 791. 高精度加法

    https://www.acwing.com/problem/content/793/ #include<bits/stdc++.h> using namespace std; vecto ...

  8. B. Game with string 思维问题转化

    B. Game with string 思维问题转化 题意 有一个字符串 每次可以删去连续的两个同样的字符,两个人轮流删,问最后谁能赢 思路 初看有点蒙蔽,仔细看看样例就会发现其实就是一个括号匹配问题 ...

  9. Linux(Ubuntu)服务器是否安装ssh,使用xshell远程连接

    1.查看 ssh 是否启动,如果有 sshd 说明已经启动 sudo ps -e | grep ssh 2.启动 ssh 服务 sudo service ssh start 3.如果第二步没有成功启动 ...

  10. 百炼OJ - 1007 - DNA排序

    题目链接:http://bailian.openjudge.cn/practice/1007 #include<stdio.h> #include<algorithm> usi ...