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=10001;
vector<int> p(6);
int N,K,M;
struct User
{
User()
{
scores.resize(6);
for(int i=1;i<=5;++i)
{
scores[i]=-2;
}
totalScores=0;
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=0,psr=0;
for(int i=1;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=1;i<=K;++i)
{
scanf("%d",&p[i]);
}
int userID,pID,partialScore;
int totalUsers=0;
for(i=0;i<M;++i)
{
scanf("%d %d %d",&userID,&pID,&partialScore);
if(partialScore==-1)
{
if(users[userID].scores[pID]<0)
users[userID].scores[pID]=0;
continue;
}
else if(partialScore>users[userID].scores[pID])
{
if(users[userID].scores[pID]>=0)
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()+1,users.begin()+N+1);
int curRank=1;
int curTotalScore=users[1].totalScores;
int j,sameRank=-1;
for(i=1;i<=totalUsers;++i)
{
if(curTotalScore>users[i].totalScores)
{
++curRank;
curRank+=sameRank;
sameRank=0;
curTotalScore=users[i].totalScores;
}
else
++sameRank;
printf("%d %.5d %d",curRank,users[i].id,users[i].totalScores);
for(j=1;j<=K;++j)
{
if(users[i].scores[j]>=0)
printf(" %d",users[i].scores[j]);
else
printf(" -");
}
printf("\n");
}
return 0;
}

PAT 1075. PAT Judge (25),布布扣,bubuko.com

时间: 2024-12-17 12:27:49

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

1075. PAT Judge

1075. PAT Judge (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT. In

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 PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT. Input Spe

1075. PAT Judge (25)

题目如下: The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT. Input Specification: Each input file contains one test case. For each case, the first

PAT(A) 1075. PAT Judge (25)

The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT. Input Specification: Each input file contains one test case. For each case, the first line

PAT甲题题解-1075. PAT Judge (25)-排序

相当于是模拟OJ评测,这里注意最后输出:1.那些所有提交结果都是-1的(即均未通过编译器的),或者从没有一次提交过的用户,不需要输出.2.提交结果为-1的题目,最后输出分数是03.某个题目从没有提交过的,输出'-' #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> #include <queue>

PAT (Advanced Level) 1075. PAT Judge (25)

简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<str

PAT:1075. PAT Judge (25) AC

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct Student { int ID; int score[6]; int perfect; int sum; int rank; bool tag; }S[10066]; int p[6]; //1-5存题号1-5小题的分值 int mp[10066]; int cnt = 0; bool cmp(Stu

PAT:1075. PAT Judge (25) 炒鸡复杂

#include<stdio.h>#include<string.h>#include<algorithm>using namespace std; struct Student{ int ID; int score[6]; int perfect; int sum; int rank;}S[10066]; int p[6]; //1-5存题号1-5小题的分值 bool cmp(Student a,Student b){ if(a.sum!=b.sum) return

【PAT甲级】1075 PAT Judge (25 分)

题意: 输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和该题得分(-1表示没通过编译).输出排名,学生ID,总分和每一题的得分,第一优先为总分降序,第二优先为题目AC数降序,第三优先为学生ID升序(提交但未通过编译得分为0,未提交得分为-,不输出没有提交或者提交全都未通过编译的学生信息). trick: 测试点4为有学生先交了得到分的程序后该题后来又交了未通过编译