Submission #1252875

#TimeUsernameProblemLanguageResultExecution timeMemory
1252875flashmtFestival (IOI25_festival)C++20
24 / 100
58 ms8244 KiB
#include "festival.h" #include <bits/stdc++.h> #ifdef LOCAL #include "Debug.h" #else #define debug(...) 42 #endif using namespace std; const long long oo = 1LL << 60; vector<int> max_coupons(int A, vector<int> P, vector<int> T) { vector<pair<int, int>> a[4]; int n = size(P); for (int i = 0; i < n; i++) a[T[i] - 1].push_back({P[i], i}); for (int i = 0; i < 4; i++) sort(begin(a[i]), end(a[i])); vector<long long> sum1 = {0}; for (auto [x, _] : a[0]) sum1.push_back(sum1.back() + x); vector<int> cur(4), fixed; long long has = A; while (1) { int found = 0; for (int t = 1; t < 4; t++) if (cur[t] < size(a[t])) { auto [p, id] = a[t][cur[t]]; long long after = min((has - p) * (t + 1), oo); if (after >= has) { has = after; cur[t]++; fixed.push_back(id); found = 1; break; } } if (!found) break; } auto get1 = [&](long long has) { return upper_bound(begin(sum1), end(sum1), has) - begin(sum1) - 1; }; vector<int> ans = {0, int(size(fixed))}; auto updateAns = [&]() { int cnt0 = get1(has); int totalCur = cnt0 + int(size(fixed)); int totalAns = ans[0] + ans[1]; if (totalCur > totalAns) ans = {cnt0, int(size(fixed))}; }; while (1) { updateAns(); long long best = -1; int bestT = -1; for (int t = 1; t < 4; t++) if (cur[t] < size(a[t])) { auto [p, _] = a[t][cur[t]]; long long after = (has - p) * (t + 1); if (after > best) { best = after; bestT = t; } } if (bestT < 0) break; has = best; fixed.push_back(a[bestT][cur[bestT]++].second); } vector<int> coupons; for (int i = 0; i < ans[1]; i++) coupons.push_back(fixed[i]); for (int i = 0; i < ans[0]; i++) coupons.push_back(a[0][i].second); return coupons; }
#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...