额。。。用一个map ,还有一个sort,
然后记住不要混乱。。。
#include <iostream>
#include<map>
#include<algorithm>
using namespace std;
char uname[13][50];
char a[50];
char b[2];
char c[10];
int defen[105];
int q; int ans = 0;
bool compare(int a, int b)//可以sort,从大到小排序
{
return a > b;
}
map<string, string> G;
int main()
{
int k = 0;
for (int i = 0; i < 4; i++)
{
cin >> uname[i];
G[uname[i]] = "gold";
}
for (int i = 4; i < 8; i++)
{
cin >> uname[i];
G[uname[i]] = "silver";
}
for (int i = 8; i <12; i++)
{
cin >> uname[i];
G[uname[i]] = "bronze";
}
int n;
cin >> n;
while (n--)
{
int ant = 0;
cin >> q;
for (int i = 0; i <q; i++)
{
cin >> a >> b >> c;
if (G[a]==c)
{
ant++;
}
}
defen[k++] = ant;//做了再k++
}
sort(defen, defen + k,compare);
for (int i = 0; i <k; i++)
{
if (defen[i] == defen[0])
ans++;
}
cout << ans * 5 << endl;
}