답안 #701606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701606 2023-02-21T15:10:18 Z GrandTiger1729 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 212 KB
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(4);
    int n; cin >> n;
    double a[n], b[n];
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a, a + n, greater<double>());
    sort(b, b + n, greater<double>());
    double prefa[n + 1]{}, prefb[n + 1]{};
    for (int i = 0; i < n; i++){
        prefa[i + 1] = prefa[i] + a[i] - 1;
        prefb[i + 1] = prefb[i] + b[i] - 1;
    }
    double ans = 0;
    int pa = 1, pb = 1;
    while (pa <= n && pb <= n){
        if (prefa[pa] > prefb[pb])
            pb++;
        else
            pa++;
        ans = max(ans, min(prefa[pa] - pb, prefb[pb] - pa));
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -