Start: Jun, 27, 2019 08:30:00
2019年度暑期短学期第二天
End: Jun, 27, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: J
Result: Accepted
Time: 566ms
Memory: 27396kB
Author: 2018212212307
In contest: 1275

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 0x3f3f3f3f;
const int maxn =1e5+10;
int n,m;
int l[30];
struct Node{
	string name;
	int x[30];
	int sorce[30];
	int all;
}aa[maxn];
int times[30]={0};
int all=0;
map<string,int>mp;
map<string,int>mp1;
void add(string s,int a)
{
	times[a]++;
	if(mp[s]>0)
	{
		aa[mp[s]].x[a]=times[a];
		return ;
	}
	all++;
	aa[all].name=s;
	mp[s]=all;
	aa[all].x[a]=times[a];
}
bool cmp(const Node& n1,const Node& n2)
{
	if(n1.all==n2.all)return mp1[n1.name]<mp1[n2.name];
	return n1.all>n2.all;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&l[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		string s;
		char c;
		cin>>s>>c;
		int a=c-'A'+1;
		add(s,a);
		mp1[s]=i;
	}
	for(int i=1;i<=all;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(aa[i].x[j]==0)continue;
			aa[i].sorce[j]+=(50*l[j]+(int)(50*l[j])/(0.8+0.2*aa[i].x[j]));
			aa[i].all+=aa[i].sorce[j];
		}
	}
	sort(aa+1,aa+1+all,cmp);
	for(int i=1;i<=all;i++)
	{
		cout<<i<<" "<<aa[i].name<<" ";
		for(int j=1;j<=n;j++)cout<<aa[i].sorce[j]<<" ";
		cout<<aa[i].all<<endl;
	}
}