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> ...
随机推荐
- EDD-SPT综合规则
关于生产运作的计算题· 很急 谢谢·有7项任务需经某设备加工,各任务资料如下.要求:(1)试用EDD-SPT综合规则确定加工顺序(2)分别计算两种规则下的平均流程时间. 任务 J1 J2 J3 J4 ...
- swap in java?
Is it possible to write a swap method in java? these two variables will be primitives. It's not poss ...
- how to increase an regular array length in java?
Arrays in Java are of fixed size that is specified when they are declared. To increase the size of t ...
- wpf之Popup弹出自定义输入"键盘"
在很多工厂的信息化MES系统中,车间的采集数据的机器是触摸屏电脑(工厂环境所限,用外接鼠标键盘反而不方便). 由于没有外接键盘,所以用户无法像坐在办公室一样,用鼠标键盘进行录入信息. 这时我们可以用w ...
- 12C cdb/pdb 配置监听
. PDB is not an instance, so using SID in the connection string will not work. When the database is ...
- regress
#! /bin/ksh ############### ### UAT ### ############### export ENVS=/test/change/env/env_test.sq ...
- OpenLayer 3 鼠标位置坐标显示控件
<body> <div id="map"> <div id="mouse-position"></div> &l ...
- idea编译报错:未结束的字符串文字;非法的表达式;未结束的字符串字面值
在idea的Settings中,找到File Encodings,将IDE Encoding 改为UTF-8 要多试几次,清除缓存什么的,具体原因不知道,不过经常第一次修改不能成功.
- Android OpenGL 入门示例----绘制三角形和正方形
Android上对OpenGl的支持是无缝的,所以才有众多3D效果如此逼真的游戏,在Camera的一些流程中也有用到GLSurfaceView的情况.本文记录OpenGL在Android上的入门级示例 ...
- Swift --> Map & FlatMap
转载自:https://segmentfault.com/a/1190000004050907 Map map函数能够被数组调用,它接受一个闭包作为参数,作用于数组中的每个元素.闭包返回一个变换后的元 ...