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 存下来 并且求出 ...
随机推荐
- strrev 字符串反转函数
strrev (PHP 3, PHP 4, PHP 5) strrev -- Reverse a string Description string strrev ( string string ) ...
- FreeMarker调用Java静态方法以及静态变量的方法
这里介绍下在类似 Spring+FreeMarker 的架构中如何在FreeMarker中访问Java中的静态方法以及静态变量. 一.首先为了方便以及可复用我们创建一个工具类 /** * FreeMa ...
- 虚拟化笔记04.OpenFiler.install
4.OpenFiler install OPENFILER 介绍 1.OpenFiler 作用 OpenFiler 基于Linux 内核,主要作用是实现IP-SAN. 在VSPHERE中我们可以将VM ...
- 微信强大的demo
https://github.com/xialeistudio/wechatPublicPlatform
- echarts(3.0)的基本使用(标签式导入)
function loadRainFallCharts(msg) { var obj = {}; obj.x = []; obj.y = []; obj.line = []; var accumula ...
- WPF 中双向绑定通知机制之ObservableCollection使用
msdn中 ObservableCollection<T> 类 表示一个动态数据集合,在添加项.移除项或刷新整个列表时,此集合将提供通知. 在许多情况下,所使用的数据是对象的集合 ...
- linux下jmeter使用帮助
1.linux下jmeter使用方法 例:jmeter -n -t test1.jmx -l logfile1.jtl -H 192.168.1.1 -P 8080 -h 帮助 -> 打印出有用 ...
- boost::asio学习(定时器)
#include <boost/asio.hpp> #include <iostream> void handle1(const boost::system::error_co ...
- codevs 必做:堆:1245、2879 并查集:1069、1074、1073
1245 最小的N个和 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 查看运行结果 题目描述 Description 有两个长度为 N ...
- Exponentiation(高精度大数)
Exponentiation Description Problems involving the computation of exact values of very large magnitud ...