1075 PAT Judge (25)
排序题
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map> using namespace std; const int N = 100005; int score[10]; struct Node
{
int id;
int problem;
int get;
}person[N]; struct ANS
{
int rank;
int id;
int total;
int get[6];
bool flag;
int perfect;
}ans[10005]; int cmp1(const ANS &a, const ANS &b)
{
if (a.total != b.total)
return a.total > b.total;
if (a.perfect != b.perfect)
return a.perfect > b.perfect;
else return a.id < b.id;
} void get_total(int n, int m, int k)
{
int i = 0, j = 0; for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
ans[i].get[j] = -2;
ans[i].flag = 0;
ans[i].perfect = 0;
} for (i = 0; i < k; i++)
{
int idx = person[i].id;
int pro = person[i].problem;
int soc = person[i].get; if (soc == score[pro] && ans[idx].get[pro] != soc)
ans[idx].perfect++;
if (soc > ans[idx].get[pro])
ans[idx].get[pro] = soc;
} for (i = 1; i <= n; i++)
{
int sum = 0;
for (j = 1; j <= m; j++)
{
if (ans[i].get[j] >= 0)
{
ans[i].flag = 1;
sum += ans[i].get[j];
}
}
ans[i].total = sum;
ans[i].id = i;
}
} void get_rank(int n)
{
int rank = 1;
int i = 0; ans[1].rank = 1;
for (i = 2; i <= n; i++)
{
if (ans[i].total == ans[i - 1].total)
ans[i].rank = ans[i - 1].rank;
else ans[i].rank = i;
}
} void print_info(int n, int m)
{
for (int i = 1; i <= n; i++)
{
if (ans[i].flag == 0) continue; printf("%d %05d %d", ans[i].rank, ans[i].id, ans[i].total); for (int j = 1; j <= m; j++)
{
if (ans[i].get[j] == -2)
printf(" -");
else if (ans[i].get[j] == -1)
printf(" 0");
else
printf(" %d", ans[i].get[j]);
} printf("\n");
}
} int main()
{
int n, m, k;
int i;
while (scanf("%d%d%d", &n, &m, &k) != EOF)
{
for (i = 1; i <= m; i++)
scanf("%d", &score[i]); for (i = 0; i < k; i++)
scanf("%d%d%d", &person[i].id, &person[i].problem, &person[i].get); //sort(person, person, cmp); get_total(n, m, k); sort(ans + 1, ans + n + 1, cmp1); get_rank(n); print_info(n, m);
}
return 0;
}
1075 PAT Judge (25)的更多相关文章
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT 1075. PAT Judge (25)
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...
- PAT (Advanced Level) 1075. PAT Judge (25)
简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstd ...
- PAT甲题题解-1075. PAT Judge (25)-排序
相当于是模拟OJ评测,这里注意最后输出:1.那些所有提交结果都是-1的(即均未通过编译器的),或者从没有一次提交过的用户,不需要输出.2.提交结果为-1的题目,最后输出分数是03.某个题目从没有提交过 ...
- 【PAT甲级】1075 PAT Judge (25 分)
题意: 输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和 ...
- PAT 1075 PAT Judge[比较]
1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
- 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 PA ...
- PAT 1075. PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...
随机推荐
- Redis3.0.1 Stable版本的集群部署(Mac)
本文档基于如下原始文档(CentOS)创建: http://blog.csdn.net/xu470438000/article/details/42971091 修改了一些路径的错误,补全了一些命令执 ...
- Eclipse 4.2 (Juno) 'Cannot create a server using the selected type' in Tomcat 7 - Stack Overflow.html
[太神奇了,真的可以呀] 原文:http://stackoverflow.com/questions/13423593/eclipse-4-2-juno-cannot-create-a-server- ...
- 经典功率谱估计及Matlab仿真
原文出自:http://www.cnblogs.com/jacklu/p/5140913.html 功率谱估计在分析平稳各态遍历随机信号频率成分领域被广泛使用,并且已被成功应用到雷达信号处理.故障诊断 ...
- SharePoint Style Library的权限问题
Style Library是属于site collection级别的. 所以如果在某一个site中直接给某个用户设置了比如Full control的权限,这个权限信息并不会自动进入Style Libr ...
- HDOJ(1348)二维凸包
Wall http://acm.hdu.edu.cn/showproblem.php?pid=1348 题目描述:有个国王想在他的城堡外面修围墙,围墙与城堡的最小距离为L,要求围墙长度最短.求围墙的长 ...
- 在sql server中利用with as实现递归功能
在sqlserver2005之前,要实现递归功能比较麻烦,比如可能会要用到临时表与while语句来循环.自sqlserver2005之后,新增了with as功能语法,即 公用表达式(CTE),让递归 ...
- Chrome54安装最新版Flash版本办法
从 Chrome54 版本开始,flash默认已经不能使用了.打开机器上的C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Pe ...
- js判断input输入框长度(支持中英文输入)
function CheckTxtLength(txt) { var num = txt.replace(/[^\x00-\xff]/g, 'xx').length; if (num <=11) ...
- 第一个PHP程序-HelloWorld
<?php //echo输出字符串 echo "Hello php!你好 php" ; 以上程序输出结果为:Hello php!你好 php
- [专题论文阅读]【分布式DNN训练系统】 FireCaffe
FireCaffe Forrest N. Iandola FireCaffe: near-linear acceleration of deep neural network training on ...