题目: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. 从网上找的Android实用代码,记录备用

    1.获取应用程序下所有Activity public static ArrayList<String> getActivities(Context ctx) { ArrayList< ...

  2. 使用LinkedHashMap来实现一个使用LRU(Least Recently Used)算法的cache

    removeEldestEntry在使用put或者putAll方法插入一个新的entry到map中时被调用,是否要删除年老的entry取决于是否满足既定的条件(比如本例中的条件:MAP中entry数量 ...

  3. Open-Source performance testing tools(From other site)

    http://www.appdynamics.com/blog/php/tools-of-the-trade-for-performance-and-load-testing/

  4. 【Android】解析Paint类中MaskFilter的使用

    目录结构: contents structure [+] EmbossMaskFilter BlurMaskFilter MaskFilter可以用来指定画笔的边缘效果.如果引用开启硬件加速的话,那么 ...

  5. java中的synchronized同步代码块和同步方法的区别

    下面这两段代码有什么区别? //下列两个方法有什么区别 public synchronized void method1(){} public void method2(){ synchronized ...

  6. Atitit 提升进度的大原则与方法  高层方法  attilax总结

    Atitit 提升进度的大原则与方法  高层方法  attilax总结 生产力的提升点 1.1. 管理,管理的发展发展非常缓慢,1 1.2. 方法论(前后分离,dsl等)1 1.3. 工具( 工具链 ...

  7. linux source code search

    https://elixir.bootlin.com/linux/latest/source/fs/eventpoll.c#L1120

  8. pandas DataFrame.shift()函数

    pandas DataFrame.shift()函数可以把数据移动指定的位数 period参数指定移动的步幅,可以为正为负.axis指定移动的轴,1为行,0为列. eg: 有这样一个DataFrame ...

  9. Git 补丁操作

    补丁是文本文件,其内容是相似于Git diff,但随着代码,它也有元数据有关提交,如提交ID,日期,提交信息等,我们可以创建补丁提交和其他人可以将它们应用到自己的资料库. Jerry 为他们的项目实现 ...

  10. MongoDB随笔3:使用索引

    创建索引的语句很简单. 1.单键索引的创建:db.test.ensureIndex({name:1},{name:'index_name'}) 2.复合索引的创建:db.test.ensureInde ...