比赛 NOIP2025模拟赛2 评测结果 AAAAAAAAAAAAAAAAAAAAAAAAA
题目名称 博彩游戏 最终得分 100
用户昵称 郑霁桓 运行时间 0.873 s
代码语言 C++ 内存使用 4.39 MiB
提交时间 2025-11-25 09:14:27
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n,l,r;
double a[100005],b[100005],s1,s2,as;
int main(){
	freopen("wager.in","r",stdin);
	freopen("wager.out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	sort(b+1,b+n+1);
	reverse(b+1,b+n+1);
	while(l<=n&&r<=n){
		if(s1<=s2){
			s1+=a[++l]-1;
			s2--;
		}else{
			s2+=b[++r]-1;
			s1--; 
		}
		as=max(as,min(s1,s2));
	}
	cout<<fixed<<setprecision(4)<<as;
	return 0;
}