답안 #309782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309782 2020-10-04T13:55:31 Z spike1236 Sure Bet (CEOI17_sure) C++14
100 / 100
351 ms 3576 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 1e5 + 10;
int n;
ld a[MAXN], b[MAXN];

ld ans;

void solve() {
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    for(int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
    for(int i = 1; i <= n; ++i) a[i] -= i, b[i] -= i;
    for(int x = 0; x <= n; ++x) {
        ld l = 0, r = 1e9, res = 0;
        for(int test = 1; test <= 100; ++test) {
            ld mid = (l + r) / 2;
            int y = a[x] - mid;
            y = min(y, n);
            if(y >= 0 && b[y] - x >= mid) res = mid, l = mid;
            else r = mid;
        }
        ans = max(ans, res);
    }
    cout << fixed << setprecision(4) << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 312 ms 3400 KB Output is correct
18 Correct 325 ms 3576 KB Output is correct
19 Correct 307 ms 3448 KB Output is correct
20 Correct 314 ms 3448 KB Output is correct
21 Correct 351 ms 3576 KB Output is correct
22 Correct 302 ms 3448 KB Output is correct
23 Correct 305 ms 3576 KB Output is correct
24 Correct 308 ms 3448 KB Output is correct
25 Correct 306 ms 3448 KB Output is correct
26 Correct 340 ms 3448 KB Output is correct