Submission #1091296

#TimeUsernameProblemLanguageResultExecution timeMemory
1091296beanCloud Computing (CEOI18_clo)C++17
100 / 100
529 ms2336 KiB
#include "bits/stdc++.h" using namespace std; struct t { int c, f, v; bool operator<(const t &other) { return f == other.f ? v < other.v : f > other.f; } }; int main() { cin.tie(0)->sync_with_stdio(0); int s = 0; vector<t> Events; int n; cin >> n; for (int i = 0; i < n; i++) { int c, f, v; cin >> c >> f >> v; v *= -1; Events.push_back({c, f, v}); s += c; } int m; cin >> m; for (int i = 0; i < m; i++) { int c, f, v; cin >> c >> f >> v; c *= -1; Events.push_back({c, f, v}); } sort(Events.begin(), Events.end()); vector<int64_t> dp(s + 1, -1e18); dp[0] = 0; for (auto &x : Events) { auto ndp = dp; for (int j = 0; j <= s; j++) { int pv = j - x.c; if (0 <= pv && pv <= s) { ndp[j] = max(ndp[j], dp[pv] + x.v); } } swap(dp, ndp); } cout << *max_element(dp.begin(), dp.end()); }
#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...