Submission #804697

#TimeUsernameProblemLanguageResultExecution timeMemory
804697Valaki2Cloud Computing (CEOI18_clo)C++14
18 / 100
2 ms1364 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int maxn = 2000; const int inf = 1e16 + 42; struct computer { int cores, freq, val; bool operator < (const computer & other) const { return freq < other.freq; } }; int n, m; vector<computer> computers, orders; vector<vector<int> > dp; void solve() { cin >> n; computers.resize(1 + n); for(int i = 1; i <= n; i++) { cin >> computers[i].cores >> computers[i].freq >> computers[i].val; } sort(computers.begin() + 1, computers.end()); cin >> m; orders.resize(1 + m); for(int i = 1; i <= m; i++) { cin >> orders[i].cores >> orders[i].freq >> orders[i].val; } sort(orders.begin() + 1, orders.end()); dp.assign(1 + n, vector<int> (1 + m, -inf)); dp[0][0] = 0; for(int i = 1; i <= n; i++) { dp[i][0] = 0; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); if(computers[i].freq >= orders[j].freq) { dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + orders[j].val - computers[i].val); } } } cout << dp[n][m] << "\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...