Submission #957371

# Submission time Handle Problem Language Result Execution time Memory
957371 2024-04-03T15:05:38 Z _callmelucian Sure Bet (CEOI17_sure) C++14
60 / 100
272 ms 3712 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const int mn = 1e5 + 5;
const ll mul = 1e6;
const ll M = 1e15;

ll a[mn], b[mn], pre_a[mn], pre_b[mn];
int n;

bool ok (ll lb) {
    // check if there exist an answer >= lb
    for (int k = 0; k <= 2 * n; k++) {
        if (pre_a[min(n, k)] < lb + k * mul) continue;
        int best = min(n, k);
        for (int b = min(n, k); b >= 1; b /= 2) {
            while (best - b >= 0 && pre_a[best - b] >= lb + k * mul) best -= b;
        }
        if (pre_b[min(n, k - best)] >= lb + k * mul) return 1;
    }
    return 0;
}

ll bs (ll L, ll R) {
    if (L == R) return L;
    ll mid = (L + R) >> 1;
    if (ok(mid + 1)) return bs(mid + 1, R);
    return bs(L, mid);
}

bool compare (ld a, ld b) { return a > b; }

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) {
        ld u, v; cin >> u >> v;
        a[i] = ll(u * mul), b[i] = (v * mul);
        //cout << a[i] << " " << b[i] << "\n";
    }
    sort(a + 1, a + 1 + n, compare);
    sort(b + 1, b + 1 + n, compare);

    for (int i = 1; i <= n; i++) {
        pre_a[i] = pre_a[i - 1] + a[i];
        pre_b[i] = pre_b[i - 1] + b[i];
    }

    cout << fixed << setprecision(4) << (ld)bs(0, M) / ld(mul) << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2520 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2520 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 3 ms 2404 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2520 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 3 ms 2404 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Incorrect 272 ms 3712 KB Output isn't correct
18 Halted 0 ms 0 KB -