답안 #471107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471107 2021-09-07T06:03:13 Z Killer2501 Sure Bet (CEOI17_sure) C++14
100 / 100
167 ms 4420 KB
#include<bits/stdc++.h>

using namespace std;
 
const int N=1e5+5;
int n;
double 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++)
    {
        cin>>a[i]>>b[i];
        a[i]*=mod;
        b[i]*=mod;
    }
    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]+(long long)b[i]-mod);
    long long l=1,r= mod * mod,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*res/mod;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 125 ms 3992 KB Output is correct
18 Correct 128 ms 4012 KB Output is correct
19 Correct 140 ms 3908 KB Output is correct
20 Correct 134 ms 3892 KB Output is correct
21 Correct 167 ms 4380 KB Output is correct
22 Correct 127 ms 3904 KB Output is correct
23 Correct 124 ms 3952 KB Output is correct
24 Correct 133 ms 4020 KB Output is correct
25 Correct 134 ms 4016 KB Output is correct
26 Correct 149 ms 4420 KB Output is correct