PAT L1-043. 阅览室
原题链接
简单
作者:
青丝蛊
,
2021-04-08 20:53:30
,
所有人可见
,
阅读 190
#include <bits/stdc++.h>
using namespace std;
typedef pair<char, int> PII;
int main()
{
int n;
cin >> n;
while (n--)
{
unordered_map<int, PII> mp;
int sum = 0, cnt = 0;
while (true)
{
int book, h, m;
char key, c;
cin >> book >> key >> h >> c >> m;
if (!book)
{
if (!cnt) puts("0 0");
else cout << cnt << ' ' << (int)(sum * 1.0 / cnt + 0.5) << endl;
break;
}
if (key == 'S')
{
mp[book].second = 60 * h + m;
mp[book].first = 'S';
}
else if (key == 'E' && mp[book].first == 'S')
{
cnt++;
sum += 60 * h + m - mp[book].second;
mp[book].first = 'E';
}
}
}
return 0;
}