#include <bits/stdc++.h>
using namespace std;
int cmp(pair<int,int>&a,pair<int,int>&b){
if(a.first == b.first)
return a.second<b.second;
return a.first < b.first;
}
int cmp1(pair<int,int>&a,pair<int,int>&b){
if(a.second == b.second)
return a.first > b.first;
return a.second > b.second;
}
int m;
vector<int>s[2];
int main(){
cin>>m;
pair<int,int>h[m];
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < m+1; ++j) {
s[i].push_back(0);
}
}
h[0].second = -1;
for (int i = 1; i < m + 1 ; ++i) {
cin>>h[i].first>>h[i].second;
}
sort(h+1,h+m+1,cmp);
for (int i = 0; i < 2; ++i) {
for (int j = 1; j < m + 1; ++j) {
if(i == 1)s[i][j] = s[i][j-1] + (h[j].second == i);
if(i == 0)s[i][j] = s[i][j-1] + (h[j-1].second == i);
}
}
for (int i = 1; i < m+1; ++i) {
int x = 0,y = 0;
x = s[1][m] - s[1][i -1];
for (int j = i; j >= 1; --j) {
if(h[j].first > h[j-1].first) {
y = s[0][j];
break;
}
}
h[i].second = x + y;
}
sort(h+1,h+m+1,cmp1);
cout<<h[1].first;
return 0;
}
csp期末预测之最佳阈值
最新推荐文章于 2024-03-26 14:55:18 发布