답안 #151213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151213 2019-09-02T08:27:18 Z karma Sure Bet (CEOI17_sure) C++14
100 / 100
155 ms 5268 KB
#include <bits/stdc++.h>
#define ld      long double
#define pb      emplace_back
#define mp      make_pair
#define fi      first
#define se      second

using namespace std;

const int N = int(1e5) + 1;
const ld eps = 1e-6;

int n;
ld a[N], b[N], res = 0, cur;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen("test.inp", "r")) {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1, greater<ld>()), sort(b + 1, b + n + 1, greater<ld>());
    for(int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
    int low, high, mid; ld x, x1;
    for(int i = 1; i <= n; ++i) {
       low = 1, high = n;
       cur = min(a[i] - i - 1, b[1] - i - 1);
       while(low <= high) {
           mid = (low + high) >> 1;
           x = min(a[i] - i - mid, b[mid] - i - mid);
           x1 = min(a[i] - i - mid + 1, b[mid - 1] - i - mid + 1);
           cur = max({cur, x, x1});
           if(x >= x1) low = mid + 1;
           else high = mid - 1;
       }
       res = max(res, cur);
    }
    cout << fixed << setprecision(4) << res;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("test.inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("test.out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 376 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 4 ms 376 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 376 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 147 ms 4888 KB Output is correct
18 Correct 143 ms 4904 KB Output is correct
19 Correct 142 ms 4856 KB Output is correct
20 Correct 142 ms 4900 KB Output is correct
21 Correct 153 ms 5240 KB Output is correct
22 Correct 144 ms 4944 KB Output is correct
23 Correct 143 ms 4856 KB Output is correct
24 Correct 145 ms 4936 KB Output is correct
25 Correct 145 ms 4856 KB Output is correct
26 Correct 155 ms 5268 KB Output is correct