답안 #800094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800094 2023-08-01T10:06:29 Z detroiddh Sure Bet (CEOI17_sure) C++17
60 / 100
96 ms 5140 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const ll maxn = 1e5 + 3 , inf = (ll)1e6;
const ll mod = 1e9 + 7;

int n;
ld eps = 1e-5;
ld a[maxn] , b[maxn];

bool ss(ld i , ld j)
{
    return i > j;
}

bool check(ld mid)
{
    int p1 = 1 , p2 = 1;
    ld so1 = 0 , so2 = 0;
    while(so1 < mid || so2 < mid)
    {
        while(so1 < mid)
        {
            if(p1 > n) return false;
            so1 += a[p1] - 1;
            so2 -= 1;
            p1++;
        }
        while(so2 < mid)
        {
            if(p2 > n) return false;
            so2 += b[p2] - 1;
            so1 -= 1;
            p2++;
        }
    }

    return true;
}

ld solve()
{
    ld lo = 0 , hi = inf , kq = 0;
    while(lo + eps <= hi)
    {
        ld mid = (lo + hi) / 2.0;
        if(check(mid))
        {
            lo = mid;
            kq = max(kq , mid);
        }
        else hi = mid;
    }

    return kq;
}

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];

   sort(a + 1 , a + n + 1 , ss);
   sort(b + 1 , b + n + 1 , ss);

   cout<<fixed<<setprecision(4)<<solve();
}
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 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 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 95 ms 4808 KB Output is correct
18 Correct 93 ms 4804 KB Output is correct
19 Correct 96 ms 4808 KB Output is correct
20 Correct 94 ms 4684 KB Output is correct
21 Incorrect 89 ms 5140 KB Output isn't correct
22 Halted 0 ms 0 KB -