Submission #56086

# Submission time Handle Problem Language Result Execution time Memory
56086 2018-07-09T22:03:39 Z gabrielsimoes Sure Bet (CEOI17_sure) C++17
100 / 100
129 ms 2988 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 1e5+10;

int n;
vector<double> va, vb;

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        double a, b;
        scanf("%lf %lf", &a, &b);
        va.push_back(a);
        vb.push_back(b);
    }

    sort(va.rbegin(), va.rend());
    sort(vb.rbegin(), vb.rend());

    for (int i = 1; i < n; i++) {
        va[i] += va[i-1];
        vb[i] += vb[i-1];
    }

    va.insert(va.begin(), 0);
    vb.insert(vb.begin(), 0);

    double ans = 0;
    for (int i = 0; i <= n; i++) {
        int l = 0, r = n;
        while (r - l > 10) {
            int m1 = l + (r - l)/3;
            int m2 = l + 2 * ((r - l)/3);

            double v1 = min(va[i] - (i + m1), vb[m1] - (i + m1));
            double v2 = min(va[i] - (i + m2), vb[m2] - (i + m2));

            if (v1 > v2) r = m2-1;
            else l = m1+1;
        }

        for (int k = l; k <= r; k++) {
            ans = max(ans, min(va[i] - (i+k), vb[k] - (i+k)));
        }
    }

    printf("%.4lf\n", ans);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sure.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 3 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 4 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 3 ms 600 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 4 ms 600 KB Output is correct
17 Correct 108 ms 2364 KB Output is correct
18 Correct 105 ms 2848 KB Output is correct
19 Correct 108 ms 2988 KB Output is correct
20 Correct 101 ms 2988 KB Output is correct
21 Correct 104 ms 2988 KB Output is correct
22 Correct 129 ms 2988 KB Output is correct
23 Correct 106 ms 2988 KB Output is correct
24 Correct 101 ms 2988 KB Output is correct
25 Correct 107 ms 2988 KB Output is correct
26 Correct 129 ms 2988 KB Output is correct