X
来源:互联网 发布:域名赎回期 编辑:程序博客网 时间:2024/05/01 12:00
Description
The International Bridge Association (IBA) has maintained, for several years, a weekly ranking of the best players in the world. Considering that each appearance in a weekly ranking constitutes a point for the player, grandpa was nominated the best player ever because he got the highest number of points.
Having many friends who were also competing against him, grandpa is extremely curious to know which player(s) took the second place. Since the IBA rankings are now available in the internet he turned to you for help. He needs a program which, when given a list of weekly rankings, finds out which player(s) got the second place according to the number of points.
Input
- in each test case there is exactly one best player and at least one second best player,
- each weekly ranking consists of M distinct player identifiers.
The end of input is indicated by N = M = 0.
Output
Sample Input
4 520 33 25 32 9932 86 99 25 1020 99 10 33 8619 33 74 99 323 62 34 67 36 79 93100 38 21 76 91 8532 23 85 31 88 10 0
Sample Output
32 331 2 21 23 31 32 34 36 38 67 76 79 88 91 93 100
代码:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
using namespace std;
struct vp
{
int x,y;
};
bool cmp(vp a,vp b)
{
if(a.y!=b.y)
return a.y>b.y;
else
return a.x<b.x;
}
int main()
{
int n,m,i,j,maxn,k,d;
vp f,v[10001];
while(scanf("%d%d",&n,&m)&&n&&m)
{
memset(v,0,sizeof(v));
for(i=0;i<n*m;i++)
{
scanf("%d",&d);
v[d].x=d;
v[d].y++;
}
sort(v,v+10000,cmp);
maxn=v[1].y;
for(i=1;i<10000;i++)
{
if(maxn==v[i+1].y)
printf("%d ",v[i].x);
else
break;
}
printf("%d\n",v[i]);
}
}
- $X
- X
- X
- X
- x
- x
- X
- /x
- x
- x
- x
- x
- x
- X
- x
- X
- %x
- +-x/
- 数学界的「 流氓大咖」
- HDU2476:String painter 区间dp
- 设计模式---观察者模式
- 加载SDRAM以及ldr,bl实现跳转的区别
- mysql初探
- X
- PCA(主成成分分析)和LDA(线性判别分析)详解-共性和区别
- fullpage.js
- 2016-2017学年第二学期C++第三章(2)
- Python leetcode #1 Two Sum
- 在安卓上部署服务器
- word2vector 一些问题及思考
- 例题 9-14 完美的服务 UVa 1218
- OpenStack Ocata 安装(八)安装过程常见报错