답안 #842788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842788 2023-09-03T11:30:59 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
72 ms 4732 KB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define x first
#define y second
#define getbit(u,i) ((u>>i)&1)
#define all(x) x.begin(),x.end()
#define N 200001
using namespace std;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
int n;
double a[N],b[N],sa[N],sb[N],ans;
double f(int na,int nb)
{
    return min(sa[na]-nb,sb[nb]-na);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    sort(a+1,a+n+1,greater<double>());
    sort(b+1,b+n+1,greater<double>());
    for(int i=1;i<=n;i++)
    {
        sa[i]=sa[i-1]+a[i]-1;
        sb[i]=sb[i-1]+b[i]-1;
    }
    for(int i=1;i<=n;i++)
    {
        int lo=-1,hi=n;
        while(hi-lo>1)
        {
            int mid=(hi+lo)>>1;
            if(f(i,mid)>f(i,mid+1)) hi=mid;
            else lo=mid;
        }
        ans=max(ans,f(i,lo+1));
    }
    cout<<setprecision(4)<<fixed<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 67 ms 4688 KB Output is correct
18 Correct 66 ms 4676 KB Output is correct
19 Correct 68 ms 4564 KB Output is correct
20 Correct 67 ms 4688 KB Output is correct
21 Correct 70 ms 4732 KB Output is correct
22 Correct 67 ms 4564 KB Output is correct
23 Correct 72 ms 4648 KB Output is correct
24 Correct 67 ms 4692 KB Output is correct
25 Correct 72 ms 4688 KB Output is correct
26 Correct 70 ms 4688 KB Output is correct