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 ...
随机推荐
- ASP.NET 访问母版页元素总结
第一种方法: 在母版页里面新建一个Label控件 <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="s ...
- Parquet与ORC:高性能列式存储格式(收藏)
背景 随着大数据时代的到来,越来越多的数据流向了Hadoop生态圈,同时对于能够快速的从TB甚至PB级别的数据中获取有价值的数据对于一个产品和公司来说更加重要,在Hadoop生态圈的快速发展过程中,涌 ...
- XidianOJ 1041: Franky的游戏O
题目描述 Franky是super的人造人,来到了n*m的棋盘世界玩冒险游戏. n×m的棋盘由n行每行m个方格组成,左上角的方格坐标是(0,0),右下角的方格坐标是(n-1,m-1). 每次游戏时,他 ...
- java spring hibernate
spring 如果配置让MultiActionController里的方法返回ModelAndView跳转到页面上 ****************************************** ...
- poj1985 Cow Marathon (求树的直径)
Cow Marathon Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 3195 Accepted: 1596 Case ...
- Office 365 系列一 ------- 如何单个安装Office 客户端和Skype for business
当我们注册好或者购买好 Office 365后,我们的单个用户如何进行在线的.流式的方式安装好我们的客户端,特别是对于我们非IT部门来说,这是一个比较为难的事情, 经常需要我们的IT去到同事的电脑旁边 ...
- Android笔记之——线程
Java: package com.example.test_ui_thread01;import android.support.v7.app.AppCompatActivity;import an ...
- wpf 遮住输入法 问题
可以参考这个代码 http://www.cnblogs.com/Leaco/p/3164394.html 当你发现没用的时候 可以改这句代码 var hwnd = ((HwndSource)Pr ...
- perl中常见的语法规则和函数
数值比较操作符 字符串 相等 == eq 不等 != ...
- LDAP与migrationtools 导入系统账号
1:安装migrationtools yum -y install migrationtools 2:修改配置文件 cd /usr/share/migrationtools 可以看到很多的文件 ...