답안 #1019637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019637 2024-07-11T06:21:18 Z overwatch9 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
using dbl = double;
int main() {
    int n;
    cin >> n;
    vector <pair <dbl, dbl>> nums(n);
    for (int i = 0; i < n; i++)
        cin >> nums[i].first >> nums[i].second;
    dbl ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        dbl l = 0;
        vector <dbl> pts;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j))
                l += nums[j].first;
            else
                pts.push_back(nums[j].second);
        }
        sort(pts.begin(), pts.end(), greater <dbl> ());
        int cnt = __builtin_popcount(i);
        dbl r = 0;
        for (auto j : pts) {
            r += j;
            cnt++;
            if (r - l >= 0.00000000001)
                break;
        }
        if (min(l, r) - cnt - ans > 0.00000000001)
            ans = min(l, r) - cnt;
    }
    cout << fixed << setprecision(4) << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -