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 ...
随机推荐
- Java基础常见英语词汇
Java基础常见英语词汇(共70个) ['ɔbdʒekt] ['ɔ:rientid]导向的 ['prəʊɡræmɪŋ]编程 OO: object ...
- Logstash 父子关系 配置
最近在使用Lostash的过程中遇到了一个问题:在一个log文件里包含两类数据,而且两类数据之间存在父子关系,那如何使用lostash的configuration实现这个需求呢 思路: 首先定义父事件 ...
- VC++ 在使用 CImage 的Draw 输入一个图像时,有时候会造成图像失真严重,解决的方法如下
VC++ 在使用 CImage 的Draw 输入一个图像时,有时候会造成图像失真严重,解决的方法如下 失真主要是由于变形造成的.只要设置一下变形的模式就可以了 ::SetStretchBltMode ...
- (转载)SPRINGMVC表单标签简介
SpringMVC表单标签简介 在使用SpringMVC的时候我们可以使用Spring封装的一系列表单标签,这些标签都可以访问到ModelMap中的内容.下面将对这些标签一一介绍. 在正式介绍Spri ...
- 几个opencv 的iOS的编译问题解决
一个iOS项目需要用到opencv,而且要支持arm64的,以前有个demo的,只支持32位的.到官网下载了最新支持64位库,结果编译无法通过. google了好久也没法解决,后来问了一个同事,找出原 ...
- 遭遇flash播放mp3诡异问题
在部分ie10+flash player 播放mp3,播放第二句话时,中断无法正常播放,(客户的机器上),自己公司的机器测试了几个,都没发现这个问题.其它浏览器(chrome,firefox)也没发现 ...
- 通过Dockerfile建立.NET Core mvc Image
生成.NET core mvc code docker run -itd microsoft/dotnet:latestdocker psdocker attach containeridmkdir ...
- Vim命令合集
1.模式切换 三种模式:命令模式,输入模式,底行模式 命令模式与输入模式之间的切换:i esc 命令模式与底行模式的切换:shift + : esc 2. 插入 i:在当前字符的左边插入 I:在当前 ...
- mac上执行sed的编辑 -i命令报错sed: 1: "test.txt": undefined label ‘est.txt’或sed: 1: "2a\test\": extra characters after \ at the end of a command
问题一 sed编辑命令:[sed -i 's/a/b/g' test.txt] 报错:sed: 1: "test.txt": undefined label 'est.txt' ...
- Android自定义控件
开发自定义控件的步骤: 1.了解View的工作原理 2. 编写继承自View的子类 3. 为自定义View类增加属性 4. 绘制控件 5. 响应用户消息 6 .自定义回调函数 一.Vie ...