Submission #1180911

#TimeUsernameProblemLanguageResultExecution timeMemory
1180911bruhhhhSure Bet (CEOI17_sure)C++20
0 / 100
0 ms324 KiB
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <cassert> #include <cmath> using namespace std; struct Book { double t, r; }; // state: 0 => skip, 1 => bet T1 (chi 1 đồng, nhận t_i nếu T1 thắng), 2 => bet RNG (chi 1 đồng, nhận r_i nếu RNG thắng) double calcGuarantee(const vector<Book>& books, const vector<int>& state) { double sumT1 = 0.0, sumRNG = 0.0; int cost = 0; int n = books.size(); for (int i = 0; i < n; i++) { if(state[i] == 1) { sumT1 += books[i].t; cost++; } else if(state[i] == 2) { sumRNG += books[i].r; cost++; } } double profitT1 = sumT1 - cost; double profitRNG = sumRNG - cost; return min(profitT1, profitRNG); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<Book> books(n); for (int i = 0; i < n; i++){ cin >> books[i].t >> books[i].r; } double bestGuarantee = -1e9; int total = 1; for (int i = 0; i < n; i++) total *= 3; for (int mask = 0; mask < total; mask++) { int tmp = mask; vector<int> state(n, 0); for (int i = 0; i < n; i++) { state[i] = tmp % 3; // 0,1,2 tmp /= 3; } double cur = calcGuarantee(books, state); bestGuarantee = max(bestGuarantee, cur); } cout << fixed << setprecision(4) << bestGuarantee << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...