#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int problem[6]={0};
struct student{
char id[20];
int is_submit[6];
int high_score[6];
int sum;
int Rank_num;
int perfect_num;
int fail_num,pass_num;
student(){
fail_num=0,pass_num=0;
for(int i=0;i<=5;i++)
is_submit[i]=0;
}
}user[1005];
bool cmp(student a,student b){
if(a.sum!=b.sum) return a.sum>b.sum;
else if(a.perfect_num!=b.perfect_num) return a.perfect_num>a.perfect_num;
else if(strcmp(a.id,b.id)!=0) return strcmp(a.id,b.id)<0;
}
int main()
{
int n,k,times;
scanf("%d%d%d",&n,&k,×);
for(int i=1;i<=k;i++) scanf("%d",&problem[i]);
int len=0; //the number of individuals
for(int i=0;i<times;i++){
char str[20]; int p_id,p_score;
scanf("%s %d %d",str,&p_id,&p_score);
int findbyid=-1; //判断当前的名字是否存在;
for(int i=0;i<len;i++){ //find the the id whether exist?
int flag=0;
for(int j=0;j<strlen(str);j++){
if(user[i].id[j]!=str[j]) flag=1;
}
if(flag==0){
findbyid=i; break;
}
}
if(findbyid==-1){ //orginal struct do not exist 没有改变,说明源结构体不存在
for(int j=0;j<strlen(str);j++) user[len].id[j]=str[j];
user[len].is_submit[p_id]=1;
if(p_score>user[len].high_score[p_id])
user[len].high_score[p_id]=p_score;
len++;
}else{
// for(int j=0;j<strlen(str);j++) user[findbyid].id[j]=str[j];
user[findbyid].is_submit[p_id]=1;
if(p_score>user[findbyid].high_score[p_id])
user[findbyid].high_score[p_id]=p_score;
}
}
for(int i=0;i<len-1;i++){
for(int j=1;j<=k;j++){ //calculate the sum;
user[i].sum+=user[i].high_score[j];
}
int key=1; //calculate the perfect num;
while(key!=k+1){
if(user[i].high_score[key]==problem[key]) user[i].perfect_num++; //==ee1
if(user[i].high_score[key]==0) user[i].pass_num++;
if(user[i].high_score[key]==-1) user[i].fail_num++;
key++;
}
}
sort(user,user+len-1,cmp);
user[0].Rank_num=1; //排名
for(int i=1;i<len-1;i++){
if(user[i-1].sum==user[i].sum) user[i].Rank_num=user[i-1].Rank_num;
else user[i].Rank_num=i+1;
}
for(int i=0;i<len-1;i++){ //output
if(user[i].fail_num==k || user[i].pass_num==k) continue;
printf("%d %s %d ",user[i].Rank_num,user[i].id,user[i].sum);
for(int j=1;j<=k;j++){
if(user[i].is_submit[j]!=0) printf("%d",user[i].high_score[j]);
else printf("-");
if(j!=k) putchar(' ');
}
if(i!=len-2)putchar('\n');
}
return 0;
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int problem[6]={0};
struct student{
char id[20];
int is_submit[6];
int high_score[6];
int sum;
int Rank_num;
int perfect_num;
int fail_num,pass_num;
student(){
fail_num=0,pass_num=0;
for(int i=0;i<=5;i++)
is_submit[i]=0;
}
}user[1005];
bool cmp(student a,student b){
if(a.sum!=b.sum) return a.sum>b.sum;
else if(a.perfect_num!=b.perfect_num) return a.perfect_num>a.perfect_num;
else if(strcmp(a.id,b.id)!=0) return strcmp(a.id,b.id)<0;
}
int main()
{
int n,k,times;
scanf("%d%d%d",&n,&k,×);
for(int i=1;i<=k;i++) scanf("%d",&problem[i]);
int len=0; //the number of individuals
for(int i=0;i<times;i++){
char str[20]; int p_id,p_score;
scanf("%s %d %d",str,&p_id,&p_score);
int findbyid=-1; //判断当前的名字是否存在;
for(int i=0;i<len;i++){ //find the the id whether exist?
int flag=0;
for(int j=0;j<strlen(str);j++){
if(user[i].id[j]!=str[j]) flag=1;
}
if(flag==0){
findbyid=i; break;
}
}
if(findbyid==-1){ //orginal struct do not exist 没有改变,说明源结构体不存在
for(int j=0;j<strlen(str);j++) user[len].id[j]=str[j];
user[len].is_submit[p_id]=1;
if(p_score>user[len].high_score[p_id])
user[len].high_score[p_id]=p_score;
len++;
}else{
// for(int j=0;j<strlen(str);j++) user[findbyid].id[j]=str[j];
user[findbyid].is_submit[p_id]=1;
if(p_score>user[findbyid].high_score[p_id])
user[findbyid].high_score[p_id]=p_score;
}
}
for(int i=0;i<len-1;i++){
for(int j=1;j<=k;j++){ //calculate the sum;
user[i].sum+=user[i].high_score[j];
}
int key=1; //calculate the perfect num;
while(key!=k+1){
if(user[i].high_score[key]==problem[key]) user[i].perfect_num++; //==ee1
if(user[i].high_score[key]==0) user[i].pass_num++;
if(user[i].high_score[key]==-1) user[i].fail_num++;
key++;
}
}
sort(user,user+len-1,cmp);
user[0].Rank_num=1; //排名
for(int i=1;i<len-1;i++){
if(user[i-1].sum==user[i].sum) user[i].Rank_num=user[i-1].Rank_num;
else user[i].Rank_num=i+1;
}
for(int i=0;i<len-1;i++){ //output
if(user[i].fail_num==k || user[i].pass_num==k) continue;
printf("%d %s %d ",user[i].Rank_num,user[i].id,user[i].sum);
for(int j=1;j<=k;j++){
if(user[i].is_submit[j]!=0) printf("%d",user[i].high_score[j]);
else printf("-");
if(j!=k) putchar(' ');
}
if(i!=len-2)putchar('\n');
}
return 0;
}