제출 #1253224

#제출 시각아이디문제언어결과실행 시간메모리
1253224haiphong5g0축제 (IOI25_festival)C++20
7 / 100
41 ms8372 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 = 1e5; const ll Inf = 1e16; ll n, a, s; vector<int> P, T; struct Coupon { ll p; ll pos; bool operator < (Coupon other) const { return p < other.p; }; }; 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) { FOR(i, 0, P.size()-1, 1) C[T[i]].pb({P[i], i}); FOR(i, 1, 4, 1) if (C[i].size()) sort(C[i].begin(), C[i].end()); ll m = (ll)C[1].size(), n = (ll)C[2].size(), p = (ll)C[3].size(), q = (ll)C[4].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; cerr << resrn << " "; 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; cerr << pos << " "; } 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...