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> ...
随机推荐
- hadoop三个配置文件的参数含义说明core-site.xml,hdfs-site.xml,mapred-site.xml
配置hadoop,主要是配置core-site.xml,hdfs-site.xml,mapred-site.xml三个配置文件,默认下来,这些配置文件都是空的,所以很难知道这些配置文件有哪些配置可以生 ...
- nginx 部署多网站
1, www 下面加一个文件夹 abc 2, 在default.conf 复制一下 ,abc.conf , 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...
- 解决Xcode 9.2系统真机测试时出现 could not find developer disk image问题
解决Xcode在ipad/iphone 9.2 系统真机测试时出现could not find developer disk image问题 第一种方法:拷贝这个文件(http://download. ...
- Oracle10 多行和并
SELECT fspc, wmsys.wm_concat (jsrzmc) as jsr FROM dxjsrxx GROUP BY fspc select fspc, LISTAGG(jsrzmc, ...
- iperf linux版本移植到android (使用工具链方式不是使用Android.mk)
由于很多程序是用makefile编译linux应用程序的,如果移植到android就要重新写Android.mk,对于不熟悉这个的人来说,特别麻烦,所以这里介绍只修改makefile就能移植到andr ...
- Linux 配置tomcat遇见的若干问题
1.提示catalina.sh缺失 原因:未对bin目录下的.sh文件授权 执行:chmod +x bin/*.sh即可 2.正常启动Tomcat 但是外界无法访问 Linux防火墙原因,进入到 et ...
- WinForm 子窗体在父窗体范围内移动,不能出父窗体 摘自于网络
详细解释:1, 主窗体Form1属性IsMdiContainer设为True,并添加ToolStrip控件, Toolstrip中添加一个按钮toolStripButton1. 2,添 ...
- linux fork()函数
C语言编程创建函数fork() 执行解析 | 浏览:1842 | 更新:2013-04-22 15:12 | 标签:c语言 概述 最近在看进程间的通信,看到了fork()函数,虽然以前用过,这次经过思 ...
- Lua 垃圾收集机制
1. 问题:一款用Lua做的游戏,玩了一段时间后会变卡 因为知道lua是有自动管理内存的机制,所以之前一直没有关注过lua内存的问题.所以今天好好的查看了lua垃圾收集机制.看了一下Lua的Garba ...
- “strcmp()” Anyone?
“strcmp()” Anyone? strcmp() is a library function in C/C++ which compares two strings. It takes two ...