Submission #1278234

#TimeUsernameProblemLanguageResultExecution timeMemory
1278234SabaKharebavaFestival (IOI25_festival)C++20
5 / 100
63 ms9584 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back const long long MOD = 9223372036854775807; bool test(long long a, vector<int> order, vector<int> p, vector<int> t) { for (int e : order) a = ((a-p[e]) * t[e]) % MOD; if (a >= 0) return true; return false; } vector<int> max_coupons(int ra, vector<int> p, vector<int> t) { int n = p.size(); long long a = ra; vector<int> order, order1; for (int i = 0; i < n; i++) { if (t[i] == 1) order1.pb(i); else order.pb(i); } sort(order.begin(), order.end(), [&](int i, int j) { if (t[i] == t[j]) { return p[i] < p[j]; } else { long long A = -p[i]*t[i]*t[j] - p[j]*t[j]; long long B = -p[j]*t[i]*t[j] - p[i]*t[i]; if (A == B) return p[i] < p[j]; return A > B; } }); sort(order1.begin(), order1.end(), [&](int i, int j) { return p[i] < p[j]; }); vector<int> ans; if (test(a, order, p, t)) { ans = order; } else { vector<bool> used(order.size(), false); bool bought; while (true) { bought = false; for (int i = 0; i < order.size(); i++) { if (used[i]) continue; else if (a >= p[order[i]]) { bought = true; a = ((a - p[order[i]]) * t[order[i]]) % MOD; ans.pb(order[i]); used[i] = true; break; } } if (!bought) break; } } for (int e : order1) { if (a >= p[e]) { ans.pb(e); a -= p[e]; } } 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...