#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 1000001;
struct node
{
int y;
int re;
}num[maxn];
int to[maxn];
map<int,int>n0;
map<int,int>n1;
map<int,int>ou;
int cmp(node &a, node &b)
{
if(a.y<b.y) return 1;
if(a.y==b.y && a.re<b.re) return 1;
return 0;
}
int main()
{
int n;
scanf("%d", &n);
int a,b;
for(int i=0; i<n; i++)
{
cin>>num[i].y>>num[i].re;
}
sort(num, num+n, cmp);
int x=0;
int tx=0;
for(int i=0; i<n; i++)
{
if(i==0) to[tx++] = num[i].y;
else
{
if(num[i-1].y!=num[i].y)
to[tx++] = num[i].y;
}
if(num[i].re==0)
{
x++;
n0[num[i].y]=x;
}
else n0[num[i].y]=x;
}
x=0;
for(int i=n-1; i>=0; i--)
{
if(num[i].re==1)
{
x++;
n1[num[i].y]=x;
}
else n1[num[i].y]=x;
}
int maxx = -1;
for(int i=0; i<tx; i++)
{
int a,b,c;
if(i==0) a=0;
else a=n0[to[i-1]];
b = n1[to[i]];
ou[to[i]] = a+b;
maxx = max(maxx, a+b);
}
map<int,int>::iterator it;
int vv=-1;
for(it=ou.begin(); it!=ou.end(); it++)
{
if(it->second==maxx)
vv = max(vv, it->first);
}
printf("%d\n", vv);
return 0;
}
202012-2 期末预测之最佳阈值
猜你喜欢
转载自blog.csdn.net/weixin_42137874/article/details/113406463
今日推荐
周排行