Submission #1306394

#TimeUsernameProblemLanguageResultExecution timeMemory
1306394olocJelly Flavours (IOI20_jelly)C++20
0 / 100
65 ms71452 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vect; #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> #define pb push_back #define f first #define s second int find_maximum_unique(int x, int y, vect a, vect b){ int n = a.size(); vector<pair<pii, int>> v; v.pb({{0, 0}, 0}); for(int i = 0; i < n; i++){ v.pb({{a[i], b[i]}, i + 1}); } sort(v.begin(), v.end()); vector<vect> dp(n + 1, vect(x + 1, 1e9)); for(int i = 0; i <= x; i++){ dp[0][i] = 0; } for(int i = 1; i <= n; i++){ for(int j = 0; j <= x; j++){ dp[i][j] = dp[i - 1][j] + v[i].f.s; if(j >= v[i].f.f) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].f.f]); } } set<pii> s; for(int i = 1; i <= n; i++){ s.insert({v[i].s, i}); } int wyn = 0; for(int i = 0; i <= n; i++){ int best = 1e9; for(int j = 0; j <= x; j++){ best = min(dp[i][j], best); } int tmp = y; if(best > tmp) continue; tmp -= best; int ile = 0; for(pii a : s){ int val = a.f; if(val > tmp) break; tmp -= val; ile++; } if(i != n){ s.erase({v[i + 1].f.s, i + 1}); } wyn = max(wyn, ile + i); } return wyn; }
#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...