답안 #409073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409073 2021-05-20T06:57:46 Z iulia13 Sure Bet (CEOI17_sure) C++14
100 / 100
185 ms 3560 KB
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
const int N = 1e5 + 5;
double a[N];
double b[N];
int main()
{
    int i, n;
    double ans = 0;
    double sumA = 0, sumB = 0;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        a[i] -= 1.0;
        b[i] -= 1.0;
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    int j = 1;
    for (i = 1; i <= n; i++)
    {
        sumA += a[i];
        sumB -= 1.0;
        double prv = min(sumA, sumB);
        ans = max(ans, prv);
        int h = j;
        while (h <= n)
        {
            if (min(sumA - 1.0, sumB + b[h]) > prv)
            {
                sumA -= 1.0;
                sumB += b[h];
                prv = min(sumA, sumB);
                ans = max(ans, prv);
                h++;
            }
            else
                break;
        }
        j = h;
    }
    cout << fixed << setprecision(4) << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 148 ms 3144 KB Output is correct
18 Correct 146 ms 3108 KB Output is correct
19 Correct 147 ms 3200 KB Output is correct
20 Correct 146 ms 3168 KB Output is correct
21 Correct 185 ms 3480 KB Output is correct
22 Correct 142 ms 3152 KB Output is correct
23 Correct 155 ms 3268 KB Output is correct
24 Correct 144 ms 3120 KB Output is correct
25 Correct 148 ms 3112 KB Output is correct
26 Correct 166 ms 3560 KB Output is correct