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 ...
随机推荐
- lettcode-102:Binary Tree Level Order Traversal (Java)
Binary Tree Level Order Traversal 二叉树的层序遍历 两种方式: 1.用两个queue交替表示每一层的节点 2.用两个node,一个表示当前层的最后一个节点,一个表示下 ...
- [转载]MongoDB C# 驱动教程
本教程基于C#驱动 v1.6.x . Api 文档见此处: http://api.mongodb.org/csharp/current/. 简介 本教程介绍由10gen支持的,用于MongoDB的C# ...
- codeforces 390D Inna and Sweet Matrix
几个小结论: 1.路径长度=i+j-1; 2.最简单的走法是先横走再竖着走或者先竖着走再横着走 #include<cstdio> #include<cstring> using ...
- HDU4528+BFS
/* bfs+标记状态 如何记录状态是关键!! */ #include<stdio.h> #include<string.h> #include<stdlib.h> ...
- 第一章 USB Type C的基本原理
图 1: USB Type C接头外形 USB Type C(简称USB-C)的基本特性: 1. 接口插座的尺寸与原来的Micro USB规格一样小,约为8.3mm X 2.5mm 2. 可承受1万次 ...
- Delphi编写自定义控件以及接口的使用(做了一个TpgDbEdit)
写给觉得自己编写Delphi很复杂的人,包括自己. Delphi自己写控件其实并不难,难的在于开发复杂的控件.(其实,编程,很多东西都是会了就不难,因此,我怕自己日后觉得自己写控件很难,特意在这记录自 ...
- RAM云存储已经出现了,就是特别贵
据说bat有这种全内存的服务器集群, RAM的问题是,容量上去了就会很费电,而且不方便做持久化,并且成本也不低,一般只能作为缓存.内存数据库,给bat.12306这种高富帅用 也有提供内存云存储的服务 ...
- android viewpager change adapter ---在使用viewpager设置新的adapter的时候发现页面还是显示旧的adapter中的值
有一个需求是当用户选择navigationview中的某一项时,右边的viewpager需要动态切换不同的adapter 发现直接setAdapter没有任何反应,加载的数据还是旧的数据 折腾了半天只 ...
- Django单元测试(二)------测试工具
The test client test client是一个python类,来模拟一个简单的“哑”浏览器,允许你来测试你的view函数.你可以使用test client完成下列事情: 1.模拟&quo ...
- Ember.js demo2
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1 ...