解题思路:单调队列优化
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
using namespace std;
#define LL long long
const int INF=0x3f3f3f3f;
int n,m;
struct node
{
char ch[30];
int x,y;
friend bool operator <(node a,node b)
{
if(a.x!=b.x) return a.x<b.x;
else return strcmp(a.ch,b.ch)>0;
}
}a[105],pre;
struct node1
{
char ch[30];
int x,y;
friend bool operator <(node1 a,node1 b)
{
if(a.y!=b.y) return a.y<b.y;
else return strcmp(a.ch,b.ch)>0;
}
}pre1;
int main()
{
while(~scanf("%d %d",&m,&n))
{
priority_queue<node>q;
priority_queue<node1>qq;
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
scanf("%s %d %d",a[j].ch,&a[j].x,&a[j].y);
q.push(a[j]);
}
for(int j=1;j<=5;j++)
{
pre=q.top();
q.pop();
strcpy(pre1.ch,pre.ch);
pre1.x=pre.x;
pre1.y=pre.y;
qq.push(pre1);
}
}
for(int i=1;i<=5;i++)
{
pre1=qq.top();
qq.pop();
printf("%s\n",pre1.ch);
}
}
return 0;
}
今天的文章HRBUST1313-火影忍者之~静音分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/63550.html