Submission #1023371

#TimeUsernameProblemLanguageResultExecution timeMemory
1023371ezGeometryCloud Computing (CEOI18_clo)C++14
100 / 100
574 ms2268 KiB
#include <iostream> #include <vector> #include <algorithm> #include <tuple> using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<tuple<ll, ll, ll>> actions; ll nCores = 0; for (ll i = 0; i < n; i++) { ll c, f, v; cin >> c >> f >> v; actions.push_back(make_tuple(f, c, -v)); nCores += c; } ll m; cin >> m; for (ll i = 0; i < m; i++) { ll c, f, v; cin >> c >> f >> v; actions.push_back(make_tuple(f, -c, v)); } sort(actions.begin(), actions.end(), greater<tuple<ll, ll, ll>>()); vector<ll> profits(nCores + 1, -4e18); profits[0] = 0; for (auto d : actions) { ll f, v, c; tie(f, c, v) = d; vector<ll> cur = profits; for (ll i = 0; i <= nCores; i++) { if (i - c < 0 or i - c > nCores) { continue; } cur[i] = max(cur[i], profits[i - c] + v); } profits = cur; } ll ans = 0; for (ll c : profits) { ans = max(ans, c); } cout << ans << endl; }
#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...