HRBUST 1313 火影忍者之~静音
2024-08-25 14:27:03
优先队列。
每次将$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 ;
}
最新文章
- XStream xml to bean
- linux下,如何把整个文件夹上传到服务器(另一台linux)
- android120 zhihuibeijing 开机页面
- MyEclipse10.0安装jad反编译插件
- Win8.1 64bit安装Genymotion模拟器
- Orchard站点性能优化-预热
- MFC常见问题以及解决方法(2)_Cstring和string互相转换
- myeclipse 的Customize Perspective 没有反应
- Visio打开或取消箭头的自动吸附和自动连接
- laravel 多对多关联 attach detach sync
- 客户端如何访问访问oracle 12c 64位的数据库
- three.js 3d三维网页代码加密的实现方法
- sudALSA lib dlmisc.c:236:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so
- VFIO简介 (转载)
- SharePoint2016配置工作流开发环境
- vi 命令集
- JS基础---->;javascript的基础(二)
- python网页爬虫 spiders_97A-04B
- HelloAndroid
- express和数据库(MySQL)的交互(二)