제출 #1252986

#제출 시각아이디문제언어결과실행 시간메모리
1252986bzzzzzzzzzz축제 (IOI25_festival)C++20
0 / 100
57 ms7604 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<int, int>> 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()); for (auto [x, i] : v2) { if ((ALL - x) * 2 >= ALL) { ALL = (ALL - x) * 2; used[i] = 1; s -= x; ans.push_back(i); if (ALL >= s) { for (int j = 0; j < n; j++) { if (used[j] == 0) { ans.push_back(j); } } return ans; } } } int l1 = 0, l2 = 0; while (true) { int 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; l1++; } else { used[v2[l2].second] = 1; ans.push_back(v2[l2].second); s -= v2[l2].first; 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...