답안 #118886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118886 2019-06-20T00:35:45 Z silxikys Sure Bet (CEOI17_sure) C++14
100 / 100
235 ms 3644 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

/*
 * max(min(Sum_{1 to n} of ai or -1,
 *         Sum_{1 to n} of bi or -1))
 * 
 */

const int maxn = 1e5+5;
int n;
double a[maxn], b[maxn];

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a+1,a+1+n,greater<double>());
    sort(b+1,b+1+n,greater<double>());
    for (int i = 1; i <= n; i++) {
        a[i] += a[i-1] - 1;
        b[i] += b[i-1] - 1;
        //cout << a[i] << ' ' << b[i] << '\n';
    }
    double maxans = 0;
    for (int i = 0; i <= n; i++) {
        int lo = 0, hi = n;
        while (lo < hi) {
            int mid = (lo+hi)/2;
            int aa = a[i] - mid;
            int bb = b[mid] - i;
            if (bb <= aa) {
                lo = mid+1;
            }
            else {
                hi = mid-1;
            }
        }
        for (int j = max(0,hi-5); j <= min(n,hi+5); j++) {
            maxans = max(maxans,min(a[i]-j,b[j]-i));
        }
    }
    printf("%.4lf\n",(double)maxans);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 135 ms 1916 KB Output is correct
18 Correct 134 ms 3164 KB Output is correct
19 Correct 140 ms 3220 KB Output is correct
20 Correct 150 ms 3280 KB Output is correct
21 Correct 235 ms 3552 KB Output is correct
22 Correct 137 ms 3192 KB Output is correct
23 Correct 136 ms 3316 KB Output is correct
24 Correct 136 ms 3340 KB Output is correct
25 Correct 138 ms 3272 KB Output is correct
26 Correct 151 ms 3644 KB Output is correct