自己看
2026-08-16 16:27:04
发布于:广东
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans1,ans2;
ll n,ma=-1e18;
struct node{
ll x;
ll y;
}a[300010];
bool cmp(node x,node y){
return x.y>y.y;
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
cin>>n;
for(ll i=1;i<=n;i++) cin>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
ll ans=0;
if(a[1].x!=a[2].x){
ans=a[1].y+a[2].y;
}else{
ans1=a[1].y+a[2].y/2;
ll cnt=1;
while(a[cnt].x==a[1].x) cnt++;
ans2=a[1].y+a[cnt].y;
ans=max(ans1,ans2);
}
cout<<ans<<endl;
//fclose(stdin);
//fclose(stdout);
return 0;
}
//coder::by::M91
这里空空如也






有帮助,赞一个