답안 #742157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742157 2023-05-15T17:18:56 Z iulia13 Sure Bet (CEOI17_sure) C++14
100 / 100
149 ms 3592 KB
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;
double a[N], b[N];
int main()
{
    int n;
    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);
    int j = 1; double sa = 0, sb = 0, ans = 0, now;
    for (int i = 1; i <= n; i++)
    {
        sa += a[i];
        sb -= 1.0;
        now = min(sa, sb);
        ans = max(ans, now);
        int jj = j;
        while (jj <= n)
        {
            if (min(sa - 1.0, sb + b[jj]) > now)
            {
                sa -= 1.0;
                sb += b[jj];
                now = min(sa, sb);
                jj++;
            }
            else
                break;
        }
        ans = max(ans, now);
        j = jj;
    }
    cout << fixed << setprecision(4) << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 121 ms 3340 KB Output is correct
18 Correct 128 ms 3168 KB Output is correct
19 Correct 134 ms 3192 KB Output is correct
20 Correct 133 ms 3156 KB Output is correct
21 Correct 149 ms 3592 KB Output is correct
22 Correct 128 ms 3148 KB Output is correct
23 Correct 141 ms 3140 KB Output is correct
24 Correct 122 ms 3156 KB Output is correct
25 Correct 125 ms 3128 KB Output is correct
26 Correct 139 ms 3536 KB Output is correct