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 ...
随机推荐
- Mac下Call to undefined function imagettftext() 解决方案
文章转载至Mac下Call to undefined function imagettftext()终极解决方案 安装了一套onethink程序准备调试,结果在登录页面发现验证码无法显示,单独访问验证 ...
- Cannot assign requested address出现的原因及解决方案
今天使用python多线程请求服务时,出现Cannot assign requested address错误 网上找了下原因,大致上是由于客户端频繁的连服务器,由于每次连接都在很短的时间内结束,导致很 ...
- C# windows form如何隐藏窗口?
you can use this line of code. It wont hide it, but it will be minimized: this.WindowState = FormWin ...
- SecureCRT的安装
SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录UNIX或Linux服务器主机的软件. SecureCRT 是高度可定制的终端仿真器,适用于 In ...
- 关于jQuery中环境配置中的问题
一开始无法显示出效果,配置和代码如 这代码本没有错 但是就是无法显示 原因是我下载了2.x版本的jQuery,jQuery2.x版本是不支持IE6/7/8的,也有很多主流的浏览器无法显示出效果,于是在 ...
- ruby 简介
Ruby 是一个注重均衡的语言,它的发明者松本行弘 Yukihiro “Matz” Matsumoto,混合了他喜欢的语言(Perl. Smalltalk. Eiffel. Ada 和 Lisp ) ...
- Generics and Collection (1)
public static void main(String args[]) { List ints = Arrays.asList(), )}); ; for(Iterator it = ints. ...
- spring mvc 第一天【注解实现springmvc的基本配置】
创建pojo,添加标识类的注解@Controller,亦可添加该Handler的命名空间:设置类的@RequestMapping(value="/hr") 该类中的方法(Handl ...
- julia的优化?
julia> function fib1(n) if n==1 return n else return n+fib1(n-1) end end fib1 (generic function w ...
- expect使用demo
#!/usr/bin/expect set timeout set ip [lindex $argv ] spawn ssh root@$ip expect { "yes/no" ...