题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075

此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定要熟练,还有就是编译没有通过为零分,没有提交显示为"-":

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std; const int NUM=;
vector<int> p();
int N,K,M;
struct User
{
User()
{
scores.resize();
for(int i=;i<=;++i)
{
scores[i]=-;
}
totalScores=;
id=NUM;
}
int id;
int totalScores;
vector<int> scores;
bool operator<(const User& rhs) const
{ if(totalScores!=rhs.totalScores)
{
return totalScores>rhs.totalScores;
}
int psl=,psr=;
for(int i=;i<=K;++i)
{
if(p[i]==scores[i])
++psl;
if(p[i]==rhs.scores[i])
++psr;
}
if(psl!=psr)
{
return psl>psr;
}
else
{
return id<rhs.id;
}
}
}; vector<User> users(NUM);
int _tmain(int argc, _TCHAR* argv[])
{
freopen("1075.txt","r",stdin);
scanf("%d %d %d",&N,&K,&M);
int i;
for(i=;i<=K;++i)
{
scanf("%d",&p[i]);
}
int userID,pID,partialScore;
int totalUsers=;
for(i=;i<M;++i)
{
scanf("%d %d %d",&userID,&pID,&partialScore);
if(partialScore==-)
{
if(users[userID].scores[pID]<)
users[userID].scores[pID]=;
continue;
}
else if(partialScore>users[userID].scores[pID])
{
if(users[userID].scores[pID]>=)
users[userID].totalScores+=partialScore-users[userID].scores[pID];
else
users[userID].totalScores+=partialScore;
users[userID].scores[pID]=partialScore;
}
if(users[userID].id==NUM)
{
users[userID].id=userID;
++totalUsers;
}
}
sort(users.begin()+,users.begin()+N+);
int curRank=;
int curTotalScore=users[].totalScores;
int j,sameRank=-;
for(i=;i<=totalUsers;++i)
{
if(curTotalScore>users[i].totalScores)
{
++curRank;
curRank+=sameRank;
sameRank=;
curTotalScore=users[i].totalScores;
}
else
++sameRank;
printf("%d %.5d %d",curRank,users[i].id,users[i].totalScores);
for(j=;j<=K;++j)
{
if(users[i].scores[j]>=)
printf(" %d",users[i].scores[j]);
else
printf(" -");
}
printf("\n");
}
return ;
}

PAT 1075. PAT Judge (25)的更多相关文章

  1. PAT 1075 PAT Judge[比较]

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

  2. PAT 1075. PAT Judge

    The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...

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

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

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

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

  5. 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 ...

  6. PAT 1085 PAT单位排行(25)(映射、集合训练)

    1085 PAT单位排行(25 分) 每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜.本题就请你实现这个功能. 输入格式: 输入第一行给出一个正整数 N(≤10​5​​),即考生人数.随 ...

  7. PTA PAT排名汇总(25 分)

    PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...

  8. PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  9. [PAT] 1141 PAT Ranking of Institutions(25 分)

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

随机推荐

  1. 关于Spring运用过程中jar包报错问题

    使用Spring进行web开发时,第一步就是导入jar包,今天使用SPring Task开发定时器时,导入了好多次jar包,都是报错,不知道是因为jar包版本不同还是因为需要依赖的jar包没加入,反正 ...

  2. 多个div并排显示的居中问题——来自腾讯的一道面试题

    前两天曲面了一下腾讯,被鄙视了... 自己太水了,且面试官对我可能也有点不爽,说什么还没叫我我就去了,可是尼玛写的面试时间是3点40,我特码进去的时候都3点50了,我还以为晚了呢,他妈的. 实现几个d ...

  3. Android-java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    章出自:luchg技术交流 http://www.luchg.com 版权所有.本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源,谢谢. Android-java.lang.Runti ...

  4. 练习--LINUX进程间通信之信号SIGNAL

    同样的,信号也不要太迷信可靠信号及不及靠信号,实时或非实时信号. 但必须要了解这些信号之间的差异,函数升级及参数,才能熟练运用. ~~~~~~~~~~~~~~~~ 信号本质 信号是在软件层次上对中断机 ...

  5. UVA 10273 Eat or Not to Eat?

    这个题目一直以为是要用图论知识来做,可是一点建图的思绪都没有,后来知道暴力便可破之.由于牛的产奶周期最大为10,1.2.3.....10的最小公倍数是MT = 2520,所以把MT作为最大的周期,然后 ...

  6. Java集合类之LinkedList链表

    package com.test; import java.util.*; public class Demo7_3 { public static void main(String[] args) ...

  7. USB (Universal Serial Bus)

    USB歷史簡介 USB規格演變 標準 USB 2.0 介面 實體層 訊號傳輸 傳輸速率 網路層 USB 通訊模型 Endpoints 傳輸型態 USB 資料連結 Transaction Frame P ...

  8. 《ArcGIS Engine+C#实例开发教程》

    原文:<ArcGIS Engine+C#实例开发教程> 摘要:<ArcGIS Engine+C#实例开发教程>,面向 ArcGIS Engine(以下简称AE)开发初学者,本教 ...

  9. HTML本地测试成功后上传博客注意事项

    需要注意不要跟博客已经存在的样式(CSS)或功能(JavaScript)起冲突 功能名一定不要一样 样式名尽量不一样 如果样式名一样,存在属性名的对应属性值尽量跟博客内相同

  10. hdu4662MU Puzzle

    http://acm.hdu.edu.cn/showproblem.php?pid=4662 I+3*U模6为2或4的都可以 一个U相当于3个I  而I只能1->2->4->8..如 ...