Submission #978821

#TimeUsernameProblemLanguageResultExecution timeMemory
978821duckindogCloud Computing (CEOI18_clo)C++17
100 / 100
311 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int n, m; int32_t main() { cin.tie(0)->sync_with_stdio(0); vector<tuple<int, bool, int, int>> vt; cin >> n; for (int i = 1; i <= n; ++i) { int c, f, p; cin >> c >> f >> p; vt.emplace_back(f, true, c, p); } cin >> m; for (int i = 1; i <= m; ++i) { int c, f, p; cin >> c >> f >> p; vt.emplace_back(f, false, c, p); } sort(vt.begin(), vt.end(), greater<>()); int MAX = 2000 * 50; vector<long long> dp(MAX + 1, -1'000'000'000'000'000'000); dp[0] = 0; for (const auto& [f, t, c, p] : vt) { if (t) for (int i = MAX; i >= c; --i) dp[i] = max(dp[i], dp[i - c] - p); else for (int i = 0; i <= MAX - c; ++i) dp[i] = max(dp[i], dp[i + c] + p); } cout << *max_element(dp.begin(), dp.end()) << "\n"; }
#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...