Submission #1091297

#TimeUsernameProblemLanguageResultExecution timeMemory
1091297beanCloud Computing (CEOI18_clo)C++14
100 / 100
497 ms2164 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; int n; cin >> n; vector<t> Events(n); for (int i = 0; i < n; i++) { int c, f, v; cin >> c >> f >> v; v *= -1; Events[i] = {c, f, v}; s += c; } int m; cin >> m; Events.resize(n + m); for (int i = 0; i < m; i++) { int c, f, v; cin >> c >> f >> v; c *= -1; Events[i + n] = {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...