제출 #1169388

#제출 시각아이디문제언어결과실행 시간메모리
1169388anteknneJelly Flavours (IOI20_jelly)C++20
100 / 100
148 ms78732 KiB
#include "jelly.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define st first #define nd second #define pb push_back const int MAXN = 2000; const int MAXX = 10 * 1000; int dp[MAXN + 1][MAXX + 1]; int minn[MAXN + 1]; vector<pii> v; priority_queue<int> pq; int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) { int n = int(a.size()); v.pb({-1, -1}); for (int i = 0; i < n; i ++) { v.pb({a[i], b[i]}); } sort(v.begin(), v.end()); for (int i = 1; i <= n; i ++) { minn[i] = INT_MAX; for (int j = 0; j <= x; j ++) { dp[i][j] = dp[i - 1][j] + v[i].nd; if (j >= v[i].st) { dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].st]); } minn[i] = min(minn[i], dp[i][j]); //cout << i << ", " << j << ": " << dp[i][j] << "\n"; } } int wyn = 0; for (int i = 0; i <= n; i ++) { //cout << i << ": " << minn[i] << "\n"; if (minn[i] > y) { continue; } while (!pq.empty()) { pq.pop(); } for (int j = i + 1; j <= n; j ++) { pq.push(-v[j].nd); } int akt = y - minn[i]; int ile = 0; while (!pq.empty() && akt + pq.top() >= 0) { akt += pq.top(); pq.pop(); ile ++; } 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...