PAT 1075. PAT Judge (25)
题目地址: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)的更多相关文章
- PAT 1075 PAT Judge[比较]
1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT 1075. PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
- 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 ...
- PAT 1085 PAT单位排行(25)(映射、集合训练)
1085 PAT单位排行(25 分) 每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜.本题就请你实现这个功能. 输入格式: 输入第一行给出一个正整数 N(≤105),即考生人数.随 ...
- PTA PAT排名汇总(25 分)
PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...
- PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- [PAT] 1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
随机推荐
- php分页类的二种调用方法(转载)
php分页类的二种调用方法 原文地址:http://www.xfcodes.com/php/fenye/25584.htm 导读:php分页类的二种调用用法,ajax调用php分页类,非ajax方式调 ...
- call()和apply()的区别
var a = function(a,b){ console.log(a+b); }, b = { c:5, d:3 }; a.call(b,1,2); a.apply(b,[1,2]); a.cal ...
- CSS跨浏览器(转)
本文将介绍兼容IE+.FF.Chrome.Safari.Opera的技巧 一.CSS HACK 专门为某版本的浏览器设置样式,从而解决浏览器显示的差异 selector { +property:val ...
- SNMP中文
SNMP4J 处理中文信息时的问题 http://qsjiangs.iteye.com/blog/1966899
- 转一贴,今天实在写累了,也看累了--【Python异步非阻塞IO多路复用Select/Poll/Epoll使用】
下面这篇,原理理解了, 再结合 这一周来的心得体会,整个框架就差不多了... http://www.haiyun.me/archives/1056.html 有许多封装好的异步非阻塞IO多路复用框架, ...
- [codility]Falling-discs
http://codility.com/demo/take-sample-test/omega2013 这题有点意思.首先经过思考,想到从底部往上扫,去迎接掉下来的disc.但这样仍然是不行的.后来看 ...
- Unicode编码的熟悉与研究过程(内附全部汉字编码列表)
我有一个问题是:是不是会有个别汉字无法在Unicode下表示,这种情况下就不能完全显示了? 各种编码查询表:http://bm.kdd.cc/ ---------------------------- ...
- Android开发UI之动画侦听
动画侦听使用了AnimationListener接口,需要实现三个方法onAnimationStart().onAnimationRepeat().onAnimationEnd() 代码: 实现But ...
- Eclipse设置、问题解决方案
Eclipse设置: 1.如何把eclipse关闭提示调出来? 可以这样打开这个提示:选择 Windows --Preferences,在左边树上选择“General” --“Startup and ...
- hdu4632Palindrome subsequence
http://acm.hdu.edu.cn/showproblem.php?pid=4632 TLE了N次 原因居然是取模次数太多了..! 这数据卡的好紧 还是我写的太搓..828ms挤过 s[i]= ...