题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032

题意:

有m次OJ提交记录,总共有k道题,n个人。每道题有一个最高分。

现在要统计用户的排名,如果总分相同,完整AC的题目数高的排前面,都一样id小的排前面。

如果没有提交记录,或者提交记录都是-1的用户,就不输出。

思路:

根据题意模拟。PAT的题目都要耐心好好读题啊,各种情况都要看清楚。

 #include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue> #define inf 0x7fffffff
using namespace std;
typedef long long LL;
typedef pair<string, string> pr; int n, k, m;
int sco[];
const int maxn = 1e4 + ;
struct node{
bool print = false;
int id;
int s[] = {-, -, -, -, -, -, -};
int sum = ;
int num = ;
}user[maxn]; bool cmp(node a, node b)
{
if(a.sum == b.sum){
if(a.num == b.num)return a.id < b.id;
return a.num > b.num;
}
return a.sum > b.sum;
} int main()
{
scanf("%d%d%d", &n, &k, &m);
for(int i = ; i <= k; i++){
scanf("%d", &sco[i]);
}
for(int i = ; i <= n; i++){
user[i].id = i;
}
for(int i = ; i <= m; i++){
string id;
int pro, s;
cin>>id>>pro>>s;
int iid = stoi(id);
if(s != -)user[iid].print = true;
if(user[iid].s[pro] == -){
if(s == -)user[iid].s[pro] = ;
else user[iid].s[pro] = s;
user[iid].sum += user[iid].s[pro];
if(user[iid].s[pro] == sco[pro])user[iid].num++;
}
else if(user[iid].s[pro] < s){
user[iid].sum += s - user[iid].s[pro];
user[iid].s[pro] = s;
if(user[iid].s[pro] == sco[pro])user[iid].num++;
}
}
sort(user + , user + + n, cmp);
int rnk = ;
for(int i = ; i <= n; i++){
if(!user[i].print)continue;
if(user[i].sum != user[i - ].sum)rnk = i;
printf("%d %05d %d", rnk, user[i].id, user[i].sum);
for(int j = ; j <= k; j++){
if(user[i].s[j] != -)printf(" %d", user[i].s[j]);
else printf(" -");
}
printf("\n");
} return ;
}

PAT甲级1075 PAT Judge的更多相关文章

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

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

  2. PAT甲级——A1075 PAT Judge

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

  3. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  4. PAT 甲级 1025 PAT Ranking

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  5. PAT 甲级 1025.PAT Ranking C++/Java

      Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...

  6. PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)

    题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...

  7. PAT甲级——A1025 PAT Ranking

    Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...

  8. PAT甲级——1025 PAT Ranking

    1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...

  9. PAT 1075 PAT Judge[比较]

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

随机推荐

  1. Quality of Service 0, 1 & 2

    来自:http://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels Quality of Servi ...

  2. Dockerfile 构建kibana 反向代理应用做用户认证访问

    FROM centos MAINTAINER z*****ch.cn RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime & ...

  3. 【CLR】详解CLR中的程序集

    目录结构: contents structure [+] 程序集的简介 为程序集分配强名称 如何指定程序集的版本资源信息 如何对程序集签名 全局程序集缓存 如何查看程序集的信息 强命名程序集防串改 1 ...

  4. 【SqlServer】解析SqlServer的分页

    方式1: 假设页数是10,现在要拿出第5页的内容,查询语句如下: --10代表分页的大小 * from test where id not in ( --40是这么计算出来的:10*(5-1) id ...

  5. Sequel Pro for Mac(MySQL 数据库管理工具)破解版安装

    1.软件简介    Sequel Pro 是一款管理 Mysql 的工具,界面简洁易用. 2.功能特色 FULL MYSQL SUPPORT Sequel Pro is a fast, easy-to ...

  6. SNF快速开发平台MVC-EasyUI3.9之-DataGrid表格控件如何增加右键菜单

    如题,我们在项目开发当中会遇到需要,表格控件增加右键菜单的使用. 下面我们就以SNF框架增加右键菜单步骤如下: 1.在加载页面当中增加如下菜单定义 <div id="mm" ...

  7. Adam算法

    结合了Momentum 和RMSprop算法的优点

  8. 【九天教您南方cass 9.1】02 从地形图上绘制纵横断面

    同学们大家好,欢迎收看由老王测量上班记出品的cass9.1视频课程, 测量空间的[九天教您南方cass]专栏是九天老师专门开设cass免费教学班.希望能帮助那些刚入行的同学,并祝您一臂之力. [点击索 ...

  9. netbeans rcp中如何编程设置主窗口标题

    http://www.th7.cn/Program/java/201510/606050.shtml ————————————————————————————————————————————————— ...

  10. Java面向对象的基本概念(对象、封装、继承、多态、抽象、接口、泛型)

    对象:是一个自包含的实体,用一组可识别的特征和行为来标识. 类:具有相同的属性和功能的对象的抽象合集.(类关键字class,首字母大写). 实例:就是一个真实的对象. 实例化:创建对象的过程,关键字是 ...