Submission #1253006

#TimeUsernameProblemLanguageResultExecution timeMemory
1253006bzzzzzzzzzzFestival (IOI25_festival)C++20
5 / 100
42 ms8372 KiB
#include <bits/stdc++.h> #include "festival.h" using namespace std; using ll = long long; std::vector<int> max_coupons(int A, std::vector<int> P, std::vector<int> T) { vector<pair<ll, ll>> v1, v2; int n = (int)P.size(); ll s = 0; ll ALL = A; vector<int> used(n, 0); for (int i = 0; i < n; i++) { if (T[i] == 1) { v1.push_back({P[i], i}); } else { v2.push_back({P[i], i}); } s += P[i]; } vector<int> ans; sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); int l1 = 0, l2 = 0; for (auto [x, i] : v2) { if ((ALL - x) * 2 >= ALL) { ALL = (ALL - x) * 2; used[i] = 1; s -= x; ans.push_back(i); } else { break; } if (ALL >= s) { for (int j = 0; j < n; j++) { if (used[j] == 0) { ans.push_back(j); } } } l2++; } while (true) { ll a = 1e9 + 1, b = 1e9 + 1; if (v1.size() > l1) { a = v1[l1].first; } if (v2.size() > l2) { b = ALL - (ALL - v2[l2].first) * 2; } if (min(a, b) > ALL) { break; } if (a < b) { used[v1[l1].second] = 1; ans.push_back(v1[l1].second); s -= a; ALL -= a; l1++; } else { used[v2[l2].second] = 1; ans.push_back(v2[l2].second); s -= v2[l2].first; ALL -= b; l2++; } if (ALL >= s) { for (int j = 0; j < n; j++) { if (used[j] == 0) { ans.push_back(j); } } return ans; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...