PAT甲级1075 PAT Judge
题目: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的更多相关文章
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT甲级——A1075 PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- PAT 甲级 1025 PAT Ranking
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- PAT 甲级 1025.PAT Ranking C++/Java
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...
- PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)
题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...
- PAT甲级——A1025 PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...
- PAT甲级——1025 PAT Ranking
1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...
- PAT 1075 PAT Judge[比较]
1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...
随机推荐
- 【PMP】合同类型
合同类型与适用场景 图形解读: 总价类 (1)固定总价类合同:货物的采购价格在一开始就已确定,并且不允许改变(除非工作范围发生变更) (2)总价加激励费合同:同会设置价格上限,高于此价格的上限的全部成 ...
- PhoneGap-Android-HTML5-WebSocket
https://github.com/FreakDev/PhoneGap-Android-HTML5-WebSocket
- file命令与magic file【转】
Linux基础——file命令与magic file [日期:2013-06-03] 来源:Linux社区 作者:sin90lzc [字体:大 中 小] //本文基于CentOS6.3 dist ...
- Smack类库详细介绍
原文地址:http://blog.csdn.net/xunshu/archive/2008/03/27/2223817.aspx Smack是一个为使用XMPP服务器聊天和发送即时消息交流而提供的库. ...
- 【iCore1S 双核心板_FPGA】例程十五:基于I2C的ARM与FPGA通信实验
实验现象: 核心代码: int main(void) { int i,n; ]; ]; HAL_Init(); system_clock.initialize(); led.initialize(); ...
- apache kylin2.10在原生hadoop集群上安装
Install Kylin Download latest Kylin binaries at http://kylin.apache.org/download Export KYLIN_HOME p ...
- php 无限分类 树形数据 格式化
测试demo ------------------------------------------------------------------------------------ <?php ...
- java二叉树字典查询(qq 928900200)
This assignment will help you practice and understand better the Binary Tree and Binary Search Tree ...
- python3 zip压缩文件压缩多个不同文件夹内的文件方法
#!/usr/bin/env python # -*- coding:utf-8 -*- import zipfile def addzip(): f = zipfile.ZipFile('test. ...
- python2.7 处理unicode和ascii字符串混用问题
python2.7默认的编码方式为ascii码,如下可以查询: import sys sys.getdefaultencoding() 如果直接在unicode和ascii字符串之间做计算.比较.连接 ...