답안 #56084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56084 2018-07-09T22:01:47 Z gabrielsimoes Sure Bet (CEOI17_sure) C++17
20 / 100
2000 ms 564 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 + (l + r)/3;
            int m2 = l + 2 * ((l + r)/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);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Execution timed out 2028 ms 564 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Execution timed out 2028 ms 564 KB Time limit exceeded
8 Halted 0 ms 0 KB -