题目: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. codeblocks技巧收集

    Ctrl+Shift+C  注释代码块 Ctrl+Shift+X  取消注释

  2. 自动化测试中CSS SELECTOR选择器的一些写法

    常见符号: #表示id .表示class >表示子元素,层级 一个空格也表示子元素,但是是所有的后代子元素,相当于xpath中的相对路径 #input 选择id为input的节点 .Volvo ...

  3. android的activity被杀死后如何重启

    最近公司的大屏展示机器人上的程序运行时间长了,比如五天,十天会出现偶尔的崩溃,查日志可能是内存溢出或者是ndk层的错误,这种错误一时也不太好查找,但是产品那边有个要求就是程序退出了一定要能重启,能抓日 ...

  4. Selenium Web 自动化 - Selenium常用API

    Selenium Web 自动化 - Selenium常用API 2016-08-01 目录 1 对浏览器操作  1.1 用webdriver打开一个浏览器  1.2 最大化浏览器&关闭浏览器 ...

  5. Emacs常用基本操作

    按键约定 组合按键 Emacs中大量的按键操作都是各式各样的组合按键(快捷键),下面是几种通常的约定: Ctrl键:表示为C Alt键:表示为M Shift键:表示为S 组合按键:比如向下移动一行的组 ...

  6. [教程]-三种空格unicode(\u00A0,\u0020,\u3000)表示的区别

    1.不间断空格\u00A0,主要用在office中,让一个单词在结尾处不会换行显示,快捷键ctrl+shift+space ; 2.半角空格(英文符号)\u0020,代码中常用的; 3.全角空格(中文 ...

  7. 在VSCode中成功安装Go相关插件问题:tools failed to install.

    一.介绍 目的:本文将主要介绍在windows使用VSCode配置Go语言环境 软件:VSCode 二.安装出现的问题 完整信息如下 Installing tools at D:\GoPath\bin ...

  8. linux安装中文输入法

    CentOS英文系统安装中文输入法,简单说说在CentOS 6.3下用yum安装中文输入法的过程.   1.需要root权限,所以要用root登录 ,或su root 2.yum install &q ...

  9. shell脚本中的逻辑判断 文件目录属性判断 if特殊用法 case判断

    case判断 • 格式 case  变量名 in                       value1)                           command            ...

  10. 使用UWA GOT优化Unity性能和内存

    优化百科: https://blog.uwa4d.com/archives/Index.html https://blog.uwa4d.com/archives/Introduction_UWAGOT ...