优先队列。

每次将$n$个人压入优先队列,取出$5$个,最后排序。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<iostream>
using namespace std; int m,n;
struct X
{
string name;
int A,B; X(string Name,int AA,int BB)
{
name = Name;
A=AA;
B=BB;
} bool operator < (const X &a) const {
if(A!=a.A) return A<a.A;
return name>a.name;
}
}; struct Y
{
string name;
int A,B;
}t[]; bool cmp2(Y a,Y b)
{
if(a.B!=b.B) return a.B>b.B;
return a.name<b.name;
} int main()
{
while(~scanf("%d%d",&m,&n))
{
priority_queue<X>Q;
int sz=;
for(int i=;i<m;i++)
{
for(int j=;j<n;j++)
{
string str; int AA,BB;
cin>>str;
scanf("%d",&AA);
scanf("%d",&BB);
Q.push(X(str,AA,BB));
} for(int j=;j<;j++)
{
X TOP = Q.top(); Q.pop();
t[sz].name = TOP.name;
t[sz].A = TOP.A;
t[sz].B = TOP.B; sz++;
}
} sort(t,t+*m,cmp2);
for(int i=;i<;i++) cout<<t[i].name<<endl; }
return ;
}

最新文章

  1. XStream xml to bean
  2. linux下,如何把整个文件夹上传到服务器(另一台linux)
  3. android120 zhihuibeijing 开机页面
  4. MyEclipse10.0安装jad反编译插件
  5. Win8.1 64bit安装Genymotion模拟器
  6. Orchard站点性能优化-预热
  7. MFC常见问题以及解决方法(2)_Cstring和string互相转换
  8. myeclipse 的Customize Perspective 没有反应
  9. Visio打开或取消箭头的自动吸附和自动连接
  10. laravel 多对多关联 attach detach sync
  11. 客户端如何访问访问oracle 12c 64位的数据库
  12. three.js 3d三维网页代码加密的实现方法
  13. sudALSA lib dlmisc.c:236:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so
  14. VFIO简介 (转载)
  15. SharePoint2016配置工作流开发环境
  16. vi 命令集
  17. JS基础----&gt;javascript的基础(二)
  18. python网页爬虫 spiders_97A-04B
  19. HelloAndroid
  20. express和数据库(MySQL)的交互(二)

热门文章

  1. css预处理器和后处理器
  2. 【C++ STL】容器的选择
  3. linux 执行shell脚本的4种方法总结
  4. Php扩展--protocolbuffers消息打包
  5. Java迭代实现斐波那契数列
  6. bzoj 1927 网络流
  7. spring boot web 入门
  8. %和format 细说
  9. 函数导出在kvm_intel.ko,kvm.ko不共享
  10. Linux 入门记录:十六、Linux 多命令协作:管道及重定向