답안 #510363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510363 2022-01-15T00:46:22 Z Monarchuwu Sure Bet (CEOI17_sure) C++17
100 / 100
133 ms 3532 KB
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef double db;

const int N = 1e5 + 9;
int n;
db a[N], b[N];

int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i];

    sort(a + 1, a + n + 1, greater<db>());
    sort(b + 1, b + n + 1, greater<db>());

    db ans(0), suma(0), sumb(0);
    int i(0), j(0);
    for (int k = 1; k <= n * 2; ++k) {
        if (i != n)
            suma += a[++i];
        else sumb += b[++j];

        while (i && j < n && min(suma, sumb) < min(suma - a[i], sumb + b[j + 1])) {
            suma -= a[i--];
            sumb += b[++j];
        }

        while (i < n && j && min(suma, sumb) < min(suma + a[i + 1], sumb - b[j])) {
            suma += a[++i];
            sumb -= b[j--];
        }

        ans = max(ans, min(suma, sumb) - k);
    }

    cout << fixed << setprecision(4) << ans << '\n';
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 117 ms 1792 KB Output is correct
18 Correct 71 ms 3172 KB Output is correct
19 Correct 84 ms 3164 KB Output is correct
20 Correct 81 ms 3224 KB Output is correct
21 Correct 82 ms 3504 KB Output is correct
22 Correct 97 ms 3180 KB Output is correct
23 Correct 117 ms 3288 KB Output is correct
24 Correct 116 ms 3116 KB Output is correct
25 Correct 110 ms 3228 KB Output is correct
26 Correct 133 ms 3532 KB Output is correct