排序题

#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)的更多相关文章

  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 1075. PAT Judge (25)

    题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...

  3. PAT (Advanced Level) 1075. PAT Judge (25)

    简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstd ...

  4. PAT甲题题解-1075. PAT Judge (25)-排序

    相当于是模拟OJ评测,这里注意最后输出:1.那些所有提交结果都是-1的(即均未通过编译器的),或者从没有一次提交过的用户,不需要输出.2.提交结果为-1的题目,最后输出分数是03.某个题目从没有提交过 ...

  5. 【PAT甲级】1075 PAT Judge (25 分)

    题意: 输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和 ...

  6. PAT 1075 PAT Judge[比较]

    1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...

  7. A1075 PAT Judge (25)(25 分)

    A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...

  8. 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 ...

  9. PAT 1075. PAT Judge

    The ranklist of PAT is generated from the status list, which shows the scores of the submittions. Th ...

随机推荐

  1. Redis的持久化的两种方式drbd以及aof日志方式

    redis的持久化配置: 主要包括两种方式:1.快照  2 日志 来看一下redis的rdb的配置选项和它的工作原理: save 900 1 // 表示的是900s内,有1条写入,则产生快照 save ...

  2. Hibernate一对一外键双向关联(Annotation配置)

    如上图所示:一个学生有一个学生证号,一个学生证号对应一名学生.在Hibernate中怎么用Annotation来实现呢? 学生类,主键是id:学生证的主键也是Id: Student.java pack ...

  3. ADURL简化程序

    using System; using System.Diagnostics; using System.Net; using System.Text; using System.Web; using ...

  4. Content has been consumed

    if(response.getEntity() != null && response.getEntity().getContent() != null) { message = IO ...

  5. Linux内核中断学习

    1.内核中断概述 (1)在OS环境下编写中断处理函数与之前在裸机中编写中断处理函数的方式是不一样的,在Linux内核中提供了一套用来管理硬件中断资源的软件体系架构. (2)在操作系统中,中断号与gpi ...

  6. javascript [object,Object]

    今天给html标签的属性赋值为对象时,发现取出来的值为 [object,Object],感觉有点奇怪. 代码如下: <!DOCTYPE html> <html> <hea ...

  7. IOS系列swift语言之课时六

    这节课需要讲的就是协议,方法,委托模式(依赖倒转) 代码刷起中...... // // main.swift // ExAndProtocol // // Created by David on 23 ...

  8. EBS 追前台最后一个执行的sql

    首先 从前台获取sid 然后 获取sql地址 ; 最后 获取sql文本 select * from v$sqltext_with_newlines t where t.ADDRESS = '07000 ...

  9. sublime中侧边栏字体大小的设置

    sublime这个编辑器相当强大,但是它的侧边栏字体实在是太小了,实在是反人类的设计,幸好它给了我们修改的机会 第一步:下载PackageResourceViewer插件,通过PackageContr ...

  10. fedora23 tweak tool不工作解决方案

    在启动器中打开 优化工具 失败 在终端中开启显示 Traceback (most recent call last): File "/usr/bin/gnome-tweak-tool&quo ...