| 比赛 |
NOIP2025模拟赛2 |
评测结果 |
AAAAAAAAAAAAAAAAAAAAAAAAA |
| 题目名称 |
博彩游戏 |
最终得分 |
100 |
| 用户昵称 |
123 |
运行时间 |
0.788 s |
| 代码语言 |
C++ |
内存使用 |
4.40 MiB |
| 提交时间 |
2025-11-25 09:11:32 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
const double eps=1e-4;
int n;
double a[N],b[N];
int main() {
freopen("wager.in","r",stdin);
freopen("wager.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%lf%lf",&a[i],&b[i]);
sort(a+1,a+n+1),sort(b+1,b+n+1);
int l=n,r=n;
double x=0,y=0,ans=0;
for (int i=1;i<=2*n;i++)
{
// if (i<=n) cout<<a[i]<<" "<<b[i]<<endl;
if (l&&x-y<-eps) x+=a[l],l--;
else if (r&&x-y>eps) y+=b[r],r--;
else
{
// cout<<"qwq "<<i<<endl;
if (l&&a[l]-b[r]>eps) x+=a[l],l--;
else y+=b[r],r--;
}
ans=max(ans,min(x,y)-1.0*i);
}
printf("%.4f",ans);
}