Submission #634790

#TimeUsernameProblemLanguageResultExecution timeMemory
634790Zian_JacobsonCloud Computing (CEOI18_clo)C++17
100 / 100
583 ms2132 KiB
#include<bits/stdc++.h> using namespace std; #define cIO ios_base::sync_with_stdio(0);cin.tie(0) #define fileIO(x) ifstream fin(string(x)+".in"); ofstream fout(string(x)+".out") #define cont(container, object) (container.find(object)!=container.end()) #define sz(x) (int) (x).size() #define ll long long #define v vector #define purc tuple<ll, bool, ll, ll>//clock rate, whether the order is a computer, number of cores, cost> const ll NEG_INF = LLONG_MIN / 2; ll n, m; int main() { vector<purc> pcs; cin >> n; for (int i = 1; i <= n; i++) { ll ci, fi, vi; cin >> ci >> fi >> vi; pcs.emplace_back(fi, true, ci, vi); } cin >> m; for (int i = 1; i <= m; i++) { ll Ci, Fi, Vi; cin >> Ci >> Fi >> Vi; pcs.emplace_back(Fi, false, Ci, Vi); } sort(pcs.begin(), pcs.end()); reverse(pcs.begin(), pcs.end()); vector<ll> dp1(50ll * n+1, NEG_INF); dp1[0] = 0; for (purc z : pcs) { vector<ll> dp2 = dp1; ll ci = get<2>(z), fi = get<0>(z), vi = get<3>(z); if (get<1>(z))// a computer { for (int d = ci; d <= 50ll * n; d++) { dp2[d] = max(dp2[d], dp1[d - ci] - vi); } } else// an order { for (int d = 0; d + ci <= 50ll * n; d++) { dp2[d] = max(dp2[d], dp1[d + ci] + vi); } } dp1 = dp2; } ll max_prof = 0; for (int i = 0; i <= 50ll * n; i++) max_prof = max(max_prof, dp1[i]); cout << max_prof << "\n"; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:36:22: warning: unused variable 'fi' [-Wunused-variable]
   36 |   ll ci = get<2>(z), fi = get<0>(z), vi = get<3>(z);
      |                      ^~
#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...