# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471108 | Killer2501 | Sure Bet (CEOI17_sure) | C++14 | 159 ms | 2752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n;
long long a[N],b[N];
long long s[N], mod = 1e9;
bool check(long long lim)
{
long long cur=0;
for(int i=1;i<=n;i++)
{
cur+=a[i];
long long mx=(cur-lim)/mod-i;
if(mx<0) continue;
mx=min(mx,1ll*n);
if(s[mx]-mod*i>=lim) return true;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n;
for(int i=1;i<=n;i++)
{
double x;
cin>> x;
a[i] =mod*x;
cin >> x;
b[i] = mod * x;
}
sort(a+1,a+n+1);
sort(b+1,b+n+1);
reverse(a+1,a+n+1);
reverse(b+1,b+n+1);
for(int i=1;i<=n;i++) s[i]=max(s[i-1],s[i-1]+b[i]-mod);
long long l=1,r=1e18,res=0;
while(l<=r)
{
long long mid=(l+r)/2;
if(check(mid))
{
res=mid;
l=mid+1;
}
else r=mid-1;
}
cout<<fixed<<setprecision(4)<<1.0*r/mod;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |