Description
下面是校赛的排名规则:
比赛期间,提交代码后,系统会返回正确或错误等结果。最后的获胜者为正确解答题目最多,如果同题数则总用时最少的队伍。
每道试题的时间花费将从竞赛开始到试题提交并且被判定为正确为止,其间每一次提交运行结果被判错误的话将被加罚20分钟时间,
未正确解答的试题不记时,如果已经返回正确的题目再重复提交则不影响结果。
例如:A、B两队都正确完成两道题目,其中A队提交这两题的时间分别是比赛开始后60分钟和165分钟,B队为80分钟和130分钟,
但B队第一个题提交了2次才通过。这样A队的总用时为60+165=225而B队为(80+20)+130=230,所以A队以总用时少而获胜。
现在给出裁判机上面所有队伍的提交时间(分钟数)和返回结果,需要你编程输出当前比赛的排行榜。
注:0题的队伍不需要输出
输入格式
每行一个评判结果,格式为:时间(第几分钟提交的)+半角空格+队名+半角空格+题号+半角空格+评判结果(0通过,其它为出错)
题号由大写A字符开始,第2题是B,依次类推,最多不超过15题
所有评判结果已经按时间排序好
输出格式
输出排名,一行一个,格式为队名+半角空格+通过题数+半角空格+罚时
注:0题的队伍不需要输出
测试数据中,没有同题且同罚时的情况
输入样例
2 abc A 4
5 abc B 0
6 def A 0
10 abc A 0
13 xyx A 4
20 def B 5
输出样例
abc 2 35
def 1 6
#include<iostream>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<vector>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stdio.h>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<iomanip>
using namespace std;
typedef long long ll;
struct acproblem
{
int cor_time=-1;
int cnt=0;
int total=0;
};
struct team
{
int num;
int punish_time;
string name;
bool operator <(const team& a)const
{
if (num != a.num) return num > a.num;
else
{
return punish_time < a.punish_time;
}
}
};
map<string, vector<acproblem>>m;
void init(string s)
{
acproblem a;
a.cor_time = -1;
for (int i = 0; i < 15; i++)
{
m[s].push_back(a);
}
}
int main()
{
//freopen("in.txt", "r", stdin);
//ios::sync_with_stdio(0);
char ch[2000]="\0";
int time, flag;
char name;
while (scanf("%d %s %c %d", &time, ch, &name, &flag)>0)
{
string s = ch;
if (m.count(s) == 0)
{
init(s);
}
if (m[s][name - 'A'].cor_time == -1)
{
if (flag == 0)
{
m[s][name - 'A'].cor_time = time;
m[s][name - 'A'].total = time + 20 * m[s][name - 'A'].cnt;
}
else
{
m[s][name - 'A'].cnt++;
}
}
}
vector<team>v;
map<string, vector<acproblem>>::iterator it = m.begin();
for (; it != m.end(); it++)
{
team a;
int time = 0;
int num = 0;
a.name = (*it).first;
for (int i = 0; i < 15; i++)
{
if ((*it).second[i].cor_time != -1)
{
num++;
time += (*it).second[i].total;
}
}
a.punish_time = time;
a.num = num;
v.push_back(a);
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++)
{
if (v[i].num)
{
cout << v[i].name << " " << v[i].num << " " << v[i].punish_time << "\n";
}
else
{
break;
}
}
}