답안 #799927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799927 2023-08-01T08:28:54 Z vjudge1 Sure Bet (CEOI17_sure) C++17
20 / 100
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const long long mul=1e5;
const int maxn=1e5+9;
long long a[maxn],b[maxn];
int n;
bool check(long long mid){
    int p=0;
    for1(i,1,2*n){
    long long need=1ll*i*mul+mid;
    for1(j,p,n){
    p=j;
    if (a[j]>=need)break;
    }
    if (a[p]<need)return false;
    if (p>i)continue;
    if (b[i-p]>=need){
    return true;
    }
    }
    return false;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("SUREBET.INP","r",stdin);
    //freopen("SUREBET.OUT","w",stdout);
    cin>>n;
    for1(i,1,n){
    long double x,y;
    cin>>x>>y;
    x=x*mul;
    y=y*mul;
    a[i]=x,b[i]=y;
    }
    sort(a+1,a+1+n,greater<long long>());
    sort(b+1,b+1+n,greater<long long>());
    for1(i,1,n){
    a[i]+=a[i-1];
    b[i]+=b[i-1];
    }
    long long l=0,r=1e14,ans=0;
    while (l<=r){
        long long mid=(l+r)/2;
        if (check(mid)){
            l=mid+1;
            ans=mid;
        }
        else r=mid-1;
    }
    long double realans=ans;
    long double realmul=mul;
    realans/=realmul;
    cout<<setprecision(4)<<fixed<<realans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -