답안 #321864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321864 2020-11-13T13:18:33 Z Karen124 Sure Bet (CEOI17_sure) C++14
100 / 100
138 ms 5228 KB
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
     
using namespace std;
     
#define ll long long int 
#define F first
#define S second
#define pb push_back
 
const ll N = 1e5 + 10;
const ll LOG = 20;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
int n;
long double a[N], b[N], ans = 0;
long double f(int i, int j){
    return min(a[i] - (long double)j, b[j] - (long double)i);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		a[i] -= 1.0; b[i] -= 1.0;
	}
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
	sort(b + 1, b + 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 = 0; i <= n; i++){
        int l = 0, r = n;
        while (l + 1 <= r){
            int mid = (l + r) / 2;
            if (f(i, mid) < f(i, mid + 1)) l = mid + 1;
            else r = mid;
        }
        ans = max(ans, f(i, r));
    }
    cout << fixed << setprecision(4) << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 128 ms 4844 KB Output is correct
18 Correct 131 ms 4972 KB Output is correct
19 Correct 134 ms 4844 KB Output is correct
20 Correct 130 ms 4844 KB Output is correct
21 Correct 136 ms 5228 KB Output is correct
22 Correct 129 ms 4844 KB Output is correct
23 Correct 129 ms 4844 KB Output is correct
24 Correct 130 ms 4812 KB Output is correct
25 Correct 131 ms 4972 KB Output is correct
26 Correct 138 ms 5228 KB Output is correct