nyoj 95
2015-07-30 10:17
113 查看
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
struct node
{
bool operator()(int &x,int &y)//优先级
{
return x>y;
}
};
priority_queue<int,vector<int>,node> que;//队列
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m,x;
scanf("%d",&m);
for(int i=0;i<m;i++)//输入数值
{
scanf("%d",&x);
que.push(x);
}
int max=0,k=1,l,a;
a=que.top();
que.pop();
while(!que.empty())
{
if(que.top()==a)//如果相等
{
que.pop();
k++;//加一
if(max<k)//更新max
{
max=k;
l=a;//记录top
}
}
else//不相等,更新a的值
{
a=que.top();
que.pop();
k=1;
}
}
printf("%d %d\n",l,max);
}
}
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
struct node
{
bool operator()(int &x,int &y)//优先级
{
return x>y;
}
};
priority_queue<int,vector<int>,node> que;//队列
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m,x;
scanf("%d",&m);
for(int i=0;i<m;i++)//输入数值
{
scanf("%d",&x);
que.push(x);
}
int max=0,k=1,l,a;
a=que.top();
que.pop();
while(!que.empty())
{
if(que.top()==a)//如果相等
{
que.pop();
k++;//加一
if(max<k)//更新max
{
max=k;
l=a;//记录top
}
}
else//不相等,更新a的值
{
a=que.top();
que.pop();
k=1;
}
}
printf("%d %d\n",l,max);
}
}
相关文章推荐
- Android开发:带progressBar效果的Button
- 算法题——像素翻转
- 下载的论文乱码
- Java模式—适配器模式
- 将博客搬至CSDN
- Xcode开发工具问题
- 7月28日全球域名商(国际域名)解析新增保有量TOP10
- sql server 2000中禁止创建表(权限设置方法)
- js dojo 读取txt
- php简单判断文本编码的方法
- gitlab 提交操作
- 常去web
- JQuery $.each跳出循环
- Javascript Map和Set
- 转---SQL SERVER 2008 利用发布订阅方式实现数据库同步
- [ActionScript 3.0] 翻牌效果,运用语法rotationY,PerspectiveProjection
- Python3抓取糗事百科
- Python3抓取糗事百科
- hdu 5323
- jmpopups获取input元素值