//终于A了,不难却觉着坑多的的题,注意-1的处理,感觉我是受memset置0的束缚了,可以把初试成绩置-1.就不用debug怎么久,注意对于-1的处理,不然漏洞百出

#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=10001;
struct node
{
int id;
int r;
int submitted;
int s[6];
int sub[6];
int perfect;
};
int per[6];
node list[maxn];
vector<node>ans;
bool cmp(node a,node b)
{
if(a.s[0]!=b.s[0])return a.s[0]>b.s[0];
else if(a.perfect!=b.perfect)return a.perfect>b.perfect;
else return a.id<b.id;
}
int main()
{
freopen("input.txt","r",stdin);
int i,j,n,k,m;
memset(per,0,sizeof(per));
memset(list,0,sizeof(list));
while(scanf("%d%d%d",&n,&k,&m)!=EOF)
{
for(i=1;i<=k;i++)scanf("%d",&per[i]);
int uid,pid,s;
for(i=0;i<m;i++)
{
scanf("%d%d%d",&uid,&pid,&s);
list[uid].id=uid;
list[uid].sub[pid]++;
if(s==-1&&list[uid].s[pid]==0) list[uid].s[pid]=-1;
else if(list[uid].s[pid]<s)list[uid].s[pid]=s;
}
for(i=0;i<maxn;i++)
{
for(j=1;j<=k;j++)
{

//if(list[i].s[j]==-1)continue;
if(list[i].s[j]>0)list[i].s[0]+=list[i].s[j];
if(list[i].sub[j]>0&&list[i].s[j]!=-1)list[i].submitted=1;
if(list[i].s[j]==per[j])list[i].perfect++;
}
if(list[i].submitted&&list[i].s[0]>=0)ans.push_back(list[i]);
}
sort(ans.begin(),ans.end(),cmp);
for(i=0;i<ans.size();i++)
{
if(i!=0&&ans[i].s[0]==ans[i-1].s[0])ans[i].r=ans[i-1].r;
else ans[i].r=i+1;
}
for(i=0;i<ans.size();i++)
{
printf("%d %05d %d",ans[i].r,ans[i].id,ans[i].s[0]);
for(j=1;j<=k;j++)
{
if(ans[i].s[j]>0)printf(" %d",ans[i].s[j]);
else if(ans[i].sub[j]>0)printf(" 0");
else printf(" -");
}
printf("\n");
}
}
return 0;
}

PAT1075. PAT Judge的更多相关文章

  1. PAT1075. PAT Judge (25)

    其中在排名输出上参照了 http://blog.csdn.net/xyzchenzd/article/details/27074665,原先自己写的很繁琐,而且还有一个测试点不通过. #include ...

  2. PAT 1075 PAT Judge[比较]

    1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...

  3. A1075 PAT Judge (25)(25 分)

    A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...

  4. PTA 10-排序5 PAT Judge (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge   (25分) The ranklist of PA ...

  5. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  6. PAT_A1075#PAT Judge

    Source: PAT A1075 PAT Judge (25 分) Description: The ranklist of PAT is generated from the status lis ...

  7. PAT Judge

    原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/677 题目如下: The ranklist of PAT is generated fr ...

  8. 10-排序5 PAT Judge

    用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...

  9. PAT 1075. PAT Judge (25)

    题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...

随机推荐

  1. MVC controller and View

    actionresult,jsonresult redirectresult partialview, viewdata, tempdata filter viewdata,只能在当前action中有 ...

  2. IGS_学习笔记03_Integrated SOA Gateway设定配置(案例)

    20150506 Created By BaoXinjian

  3. AP_AP系列 - 发票管理分析(案例)

    2014-07-07 Created By BaoXinjian

  4. DB2 SQL性能调优秘笈

    SQL优化技巧 1.去除在谓词列上编写的任何标量函数 2.去除在谓词列上编写的任何数学运算 3.SQL语句的Select部分只写必要的列 4.尽可能不用Distinct 5.尽量将In子查询重写为Ex ...

  5. Python标准库03 路径与文件 (os.path包, glob包)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 路径与文件的简介请参看Linux文件系统 os.path包 os.path包主要是 ...

  6. KVC , KVO , KVB

    来源:http://www.cnblogs.com/jay-dong/archive/2012/12/13/2815778.html 熟悉oc语法的同学也许都会懂得这么一点:在oc中,类的成员变量或是 ...

  7. 第3章 System V IPC

    3.1 概述 System V IPC 包含:System V消息队列.System V信号量.System V共享内存. 3.2 key_t 键和 ftok函数 这三种类型的System V IPC ...

  8. dede文章页调用当前栏目链接方法

    DedeCMS内容页调用当前栏目其实用下来是调用不出来的,{dede:field.typename/}是有效的,可是 {dede:field.typeurl/}却调不出文档当前栏目所在目录链接URL. ...

  9. [Java] java中的接口定义

    在Java的通常规范中,对数据成员的修改要通过接口提供的方法进行(如下面示例中接口中的void learnMath(int hours)和void learnEnglish(int hours)),这 ...

  10. 你可能不知道的 30 个 Python 语言的特点技巧

        列表按难度排序,常用的语言特征和技巧放在前面. 1.1   分拆 >>> a, b, c = 1, 2, 3>>> a, b, c(1, 2, 3)> ...