PAT (Advanced Level) 1075. PAT Judge (25)
简单模拟题。
注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名。
如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std; const int maxn=+;
int n,k,m;
int val[]; struct X
{
int Rank;
int num;
int id;
int tot;
int get[];
}s[maxn],ans[maxn];
int sz; bool cmp(const X&a,const X&b)
{
if(a.tot==b.tot&&a.num==b.num) return a.id<b.id;
if(a.tot==b.tot) return a.num>b.num;
return a.tot>b.tot;
} int main()
{
scanf("%d%d%d",&n,&k,&m);
for(int i=;i<=k;i++) scanf("%d",&val[i]);
for(int i=;i<=n;i++)
{
s[i].id=i;
s[i].num=;
s[i].tot=;
for(int j=;j<=k;j++) s[i].get[j]=-;
} for(int i=;i<=m;i++)
{
int id,pro,get;
scanf("%d%d%d",&id,&pro,&get);
s[id].get[pro]=max(s[id].get[pro],get);
} sz=;
for(int i=;i<=n;i++)
{
int fail=;
for(int j=;j<=k;j++)
if(s[i].get[j]>=) fail=;
if(fail==) continue;
ans[sz++]=s[i];
} for(int i=;i<sz;i++)
for(int j=;j<=k;j++)
if(ans[i].get[j]==-) ans[i].get[j]=; for(int i=;i<sz;i++)
{
for(int j=;j<=k;j++)
{
if(ans[i].get[j]==-) continue;
ans[i].tot=ans[i].tot+ans[i].get[j];
if(ans[i].get[j]==val[j]) ans[i].num++;
}
} sort(ans,ans+sz,cmp); ans[].Rank=;
for(int i=;i<sz;i++)
{
if(ans[i].tot==ans[i-].tot)
ans[i].Rank=ans[i-].Rank;
else ans[i].Rank=i+;
} for(int i=;i<sz;i++)
{
printf("%d %05d %d",ans[i].Rank,ans[i].id,ans[i].tot);
for(int j=;j<=k;j++)
{
printf(" ");
if(ans[i].get[j]==-) printf("-");
else printf("%d",ans[i].get[j]);
}
printf("\n");
} return ;
}
PAT (Advanced Level) 1075. PAT Judge (25)的更多相关文章
- PTA(Advanced Level)1075.PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT (Advanced Level) 1109. Group Photo (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
- PAT (Advanced Level) 1101. Quick Sort (25)
树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...
- PAT (Advanced Level) 1071. Speech Patterns (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1063. Set Similarity (25)
读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...
- PAT (Advanced Level) 1059. Prime Factors (25)
素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- PAT (Advanced Level) 1051. Pop Sequence (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- git远程分支--remote
查看所有远程引用: $ git ls-remote From ssh://someone@example/testgit ebf3ef7551603cd57a699e80db0bfab36d1aa7b ...
- 认识ASP.NET MVC的5种AuthorizationFilter
在总体介绍了筛选器及其提供机制(<深入探讨ASP.NET MVC的筛选器>)之后,我们按照执行的先后顺序对四种不同的筛选器进行单独介绍,首先来介绍最先执行的AuthorizationFil ...
- ios 中NSArray
// #import <Foundation/Foundation.h> #import "Animal.h" int main(int argc, const cha ...
- javascript操作json
for (var i = 0; i < selectedPartList.length; i++) { if (selectedPartList[i].vpart_code == jsonRow ...
- ASP:GB2312格式文本文件转换成UTF-8格式
'-------------------------------------------------'函数名称:gb2utf_file'作用:利用AdoDb.Stream对象来把GB2312格式文本文 ...
- eclipse无法导入已有android项目
问题: 今天发现我拷贝的一个android项目无法导入到eclipse,但是其它的已有android项目却可以导入 思路 现在网络这么流行,当然是上网查,得益于eclipse无法导入Android工程 ...
- WPF(ContentControl和ItemsControl)
WPF(ContentControl和ItemsControl) 2013-04-01 16:25 2188人阅读 评论(0) 收藏 举报 分类: .Net(C#)(31) WPF(25) 版权 ...
- CodeForces 566B Replicating Processes
#include <bits/stdc++.h> #define N 3010 #define LL long long #define unsigned U using namespac ...
- Java的引用c++的引用和C指针的区别
Java的引用本质上就是C中的指针,而c++的引用则完全不同:有一个类 class Point { int x; int y;} 同样的一个Point p; 在Java中p表示一个引用,它等同于C语言 ...
- ACE_Time_Value
头文件“Time_Value.h” 为了兼容各个平台的时间特性,ACE Reactor框架提供了ACE_Time_Value类.ACE_Time_Value的关键方法见下图3.2和表3.2.3.3: ...