Submission #807533

#TimeUsernameProblemLanguageResultExecution timeMemory
807533Valaki2Cloud Computing (CEOI18_clo)C++14
100 / 100
328 ms1364 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int maxn = 2000; const int maxc = 50; const int inf = 1e16 + 42; struct computer { int cores, freq, val; bool real; bool operator < (const computer & other) const { if(freq == other.freq) { return real > other.real; } return freq > other.freq; } }; int n, m; vector<computer> all; vector<int> dp; void solve() { cin >> n; for(int i = 1; i <= n; i++) { computer cur; cin >> cur.cores >> cur.freq >> cur.val; cur.real = true; all.pb(cur); } cin >> m; for(int i = 1; i <= m; i++) { computer cur; cin >> cur.cores >> cur.freq >> cur.val; cur.real = false; all.pb(cur); } sort(all.begin(), all.end()); dp.assign(1 + maxn * maxc, -inf); dp[0] = 0; for(computer cur : all) { if(cur.real) { for(int i = maxn * maxc; i >= cur.cores; i--) { dp[i] = max(dp[i], dp[i - cur.cores] - cur.val); } } else { for(int i = 0; i <= maxn * maxc - cur.cores; i++) { dp[i] = max(dp[i], dp[i + cur.cores] + cur.val); } } } int ans = 0; for(int i = 0; i <= maxn * maxc; i++) { ans = max(ans, dp[i]); } cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }
#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...