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 a.sum>b.sum;
else if(a.perfect!=b.perfect)
return a.perfect>b.perfect;
else
return a.ID<b.ID;
}

int main()
{
memset(S,0,sizeof(S));
int n,k,m; //n个人,k道题,提交量m
scanf("%d%d%d",&n,&k,&m);
for(int i=1 ; i<=k ; ++i)
scanf("%d",&p[i]); //存入分值
for(int i=0 ; i<m ; ++i)
{
int name,score,testnum;
scanf("%d %d %d",&name, &testnum, &score);

S[name].score[testnum]=score;
if(score==p[testnum]) //此题满分
++S[name].perfect;
if(score!=-1)
S[name].sum+=score; //更新总分
}
sort(S,S+n,cmp);

S[0].rank=1;
for(int i=1 ; i<n ; ++i) //生成排名
{
if(S[i].score==S[i-1].score) //【skill】分数不同,排名为i+1;分数相同,排名还是前一个,不变
S[i].rank=S[i].rank;
else
S[i].rank=i+1;
}

for(int i=0 ; i<n ; ++i) //输出
{
if(S[i].sum!=0) //该同学存在有效成绩
{
printf("%d %05d",S[i].rank, S[i].ID);
for(int j=1 ; j<=k ; ++j)
{
if(S[i].score[j]!=-1) //不是-1输出成绩
printf(" %d",S[i].score[j]);
else //是-1,输出“-”
printf(" -");
}
}
printf("\n");
}
return 0;
}

时间: 2024-10-18 06:24:53

PAT:1075. PAT Judge (25) 炒鸡复杂的相关文章

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

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

NBUT 1576 炒鸡想减肥的字符串

借鉴了  nenu_xlp  的思想: 先把'a'到'a'+m-1的字符找到,在将其中的序号最大的减去最小的,在不断更新每个字母对应的序号,重复之前的步骤比较的出最小的结果.. #include<stdio.h> #include<string.h> #include<math.h> #include<iostream> using namespace std; int t[27]; char s[1005]; int q[27]; int b,c; int

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