PAT 天梯赛 L1-043. 阅览室 【STL】
题目链接
https://www.patest.cn/contests/gplt/L1-043
思路
将每一次 借出和归还 都用 MAP 标记 如果归还的时候 已经被标记过了 那么 ANS ++ 并且 TIME 也加上相应时间
最后 算一下平均时间 要四舍五入
AC代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <cstdlib>
#include <ctype.h>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
struct node
{
int time;
int flag;
};
int main()
{
int t;
cin >> t;
a:
while (t--)
{
map <string, node> m;
m.clear();
string ID;
char vis;
int h, mins;
int ans = 0;
int time = 0;
while (cin >> ID)
{
scanf(" %c %02d:%02d", &vis, &h, &mins);
if (ID == "0")
{
if (ans > 0)
time = (int)(time*1.0/ans + 0.5);
printf("%d %d\n", ans, time);
goto a;
}
else
{
if (vis == 'S')
{
m[ID].time = h * 60 + mins;
m[ID].flag = 1;
}
else if (vis == 'E')
{
if (m[ID].flag == 1)
{
ans ++;
time += (h * 60 + mins) - m[ID].time;
m.erase(ID);
}
}
}
}
}
}
PAT 天梯赛 L1-043. 阅览室 【STL】的更多相关文章
- PTA 天梯赛 L1
L1-002 打印沙漏 细节:就是在 (i>j&&i+j<r+1) 这个区间里才有空格,然后就是 for 循环 for(r=1; ;r+=2) 条件不满足之后还会再 ...
- PAT天梯赛 L1-049 天梯赛座位分配
题目链接:点击打开链接 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i 所学校有 M[i] ...
- PAT天梯赛L3-007 天梯地图
题目链接:点击打开链接 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校所在地和赛场地点后,该地图应该推荐两条路线:一条是最快到达路线:一条是最短距离的路线.题目保证对任意的查询请求,地图上都至 ...
- PAT天梯赛练习题——L3-007. 天梯地图(多边权SPFA)
L3-007. 天梯地图 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校 ...
- PAT 天梯赛 L1-043 阅览室
L1-043. 阅览室 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 天梯图书阅览室请你编写一个简单的图书借阅统计程序.当读者 ...
- PAT 天梯赛 L2-012. 关于堆的判断 【Heap】【STL】
题目链接 https://www.patest.cn/contests/gplt/L2-012 思路 使用 STL 里面有关 Heap 的函数 std::make_heap将[start, end)范 ...
- PAT 天梯赛 L1-030. 一帮一 【STL】
题目链接 https://www.patest.cn/contests/gplt/L1-030 思路 用三个 Vector 来分别存放 整个排名,以及男生的单独排名和女生的单独排名 从整个的排名 从上 ...
- PAT 天梯赛 L1-020. 帅到没朋友 【STL】
题目链接 https://www.patest.cn/contests/gplt/L1-020 思路 对于每个 K >= 2 的朋友圈,里面的所有 ID 都用 MAP 标记一下 对于每个 K = ...
- PAT天梯赛 L2-019. 悄悄关注 【STL】
题目链接 https://www.patest.cn/contests/gplt/L2-019 思路 将已关注的人 用 MAP存起来 然后将点赞的用户中 没有关注的 用 VECTOR 存下来 并且求出 ...
随机推荐
- App上架注意事项(转)
上传不出现构建版本 现在苹果要求先上传版本,然后在提交审核,但是现在经常上传完应用后,不出现构建版本,等待很久很久,也不出现,那么怎么解决,我告诉你~~尼玛的苹果是自己数据丢包了,结果就造成你不出现构 ...
- iOS_25_彩票骨架搭建+导航栏适配
终于效果图: Main.storyboard 初始化的控制器是:导航控制器 它的根控制器是:TabBarController TabBarController的底部是一个自己定义的TabBar 里面加 ...
- DataUml Design 介绍9 - DataUML 1.3版本功能(查询分析器功能等)
DataUML 1.3 (下载)主要更新内容如下: 1.增加查询分析器功能: 2.增加打开历史文件记录功能: 3.修改查询对象功能: 4.增加显示对象长度功能: 5.增加配置显示表字段功能: 6.增加 ...
- PHPWord使用方法
官方文档 github地址 一.安装 直接使用composer安装,链接地址 composer require phpoffice/phpword 二.简单使用 require_once 'PhpO ...
- 虚拟化笔记04.OpenFiler.install
4.OpenFiler install OPENFILER 介绍 1.OpenFiler 作用 OpenFiler 基于Linux 内核,主要作用是实现IP-SAN. 在VSPHERE中我们可以将VM ...
- redhat6.5安装postgresql8.4数据库
Redhat6.5安装postgresql8.4数据库 step1 先移除原有的postgresql数据库(如果有),否则直接跳过 rpm -qa | grep postgresql* rpm -ev ...
- Hive查询错误:FAILED: RuntimeException Cannot make directory: hdfs://
解决方法,关闭hadoop安全模式: hadoop dfsadmin -safemode leave
- yii rule
https://blog.csdn.net/ljfrocky/article/details/46373691 http://www.yiichina.com/tutorial/997 http:// ...
- php读取xml的神器
<?xml version="1.0 encoding="UTF-8"?> <humans> <zhangying> <name ...
- iOS学习笔记(四)——iOS应用程序生命周期
开发应用程序都要了解其生命周期,开始接触android时也是从应用程序生命周期开始的,android的应用程序生命周期更多是其组件的生命周期,例如Activity.Service.今天我们接触一下iO ...