Submission #1258562

#TimeUsernameProblemLanguageResultExecution timeMemory
1258562haiphong5g0Festival (IOI25_festival)C++20
0 / 100
47 ms11956 KiB
//#include "souvenirs.h" #include <bits/stdc++.h> #define task "TEST" #define task2 "A" #define pl pair<ll, ll> #define pf push_front #define pb push_back #define pob pop_back #define pof pop_front #define mp make_pair #define fi first #define se second #define FOR(i, a, b, c) for (int i=a; i<=b; i+=c) #define FORE(i, a, b, c) for (int i=a; i>=b; i+=c) using namespace std; using ll = long long; using Knowledge = pair<vector<int>, ll>; using ull = unsigned long long; const int Mod = 998244353; const int maxn = 3e5; const ll Inf = 1e16; ll n, a, s; vector<int> P, T; struct Coupon { ll p, num; ll pos; bool operator > (Coupon other) const { return p*num*other.num + other.p*other.num < other.p*other.num*num + p*num; }; }; vector<Coupon> C[5]; ll Fix(ll& i, ll& j, ll& k, ll& h, ll pos, ll add) { ll v; if (pos == 1) i += add, v = i; if (pos == 2) j += add, v = j; if (pos == 3) k += add, v = k; if (pos == 4) h += add, v = h; return v; } vector<int> max_coupons(int s, vector<int> P, vector<int> T) { vector<Coupon> S[3]; vector<int> res; FOR(i, 0, P.size()-1, 1) { if (T[i] == 1) S[1].pb({P[i], T[i], i}); else S[2].pb({P[i], T[i], i}); } sort(S[2].begin(), S[2].end(), greater<Coupon>()); ll m = (ll)C[1].size(), n = (ll)C[2].size(); ll ans, sum[maxn+1], resrn = s, pos = -1; FOR(i, 0, m-1, 1) sum[i] = (i == 0 ? C[1][0].p : C[1][i].p + sum[i-1]); ans = upper_bound(sum, sum + m, resrn) - sum; FOR(i, 0, n-1, 1) { resrn = (resrn - C[2][i].p) * 2; if (resrn < 0) break; if (resrn > Inf) resrn = Inf; ll v = i + 1 + (upper_bound(sum, sum + m, resrn) - sum); if (v > ans) pos = i, ans = v; } vector<int> ret; ret.clear(); FOR(i, 0, pos, 1) ret.pb(C[2][i].pos); FOR(i, 0, ans-pos-2, 1) ret.pb(C[1][i].pos); return ret; }
#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...