Submission #1019636

# Submission time Handle Problem Language Result Execution time Memory
1019636 2024-07-11T06:20:20 Z overwatch9 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 348 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)
                break;
        }
        ans = max(ans, min(l, r) - cnt);
    }
    cout << fixed << setprecision(4) << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -