Submission #1011943

#TimeUsernameProblemLanguageResultExecution timeMemory
1011943ThunnusCloud Computing (CEOI18_clo)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define fi first #define se second #define sz(x) (int)(x).size() signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, m, c, f, v, tot_core = 0; cin >> n; vector<array<int, 3>> inp; for(int i = 0; i < n; i++){ cin >> c >> f >> v; tot_core += c; inp.push_back({c, f, -v}); } cin >> m; for(int i = 0; i < m; i++){ cin >> c >> f >> v; inp.push_back({-c, f, v}); } sort(inp.begin(), inp.end(), [&](array<int, 3> &a, array<int, 3> &b) {return (a[1] == b[1] ? a[2] < b[2] : a[1] > b[1]);} ); vi dp(tot_core + 1, INT64_MIN); dp[0] = 0; for(int i = 0; i < sz(inp); i++){ array<int, 3> ar = inp[i]; vi ndp(dp); for(int c = 0; c <= tot_core; c++){ int nval = c - ar[1]; if(nval >= 0 && nval <= tot_core && dp[nval] != INT64_MIN) ndp[c] = max(ndp[c], dp[nval] + ar[2]); } dp = ndp; } cout << *max_element(dp.begin(), dp.end()); return 0; } // {number of cores(c), the clock rate(f), the price(v)}
#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...