Submission #752845

#TimeUsernameProblemLanguageResultExecution timeMemory
752845nguyenneheheCloud Computing (CEOI18_clo)C++14
100 / 100
703 ms2116 KiB
#include<bits/stdc++.h> using namespace std; signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<array<int, 4>> a; int sumc = 0; for (int i = 0; i < n; ++i) { int c, f, v; cin >> c >> f >> v; a.push_back({c, f, -v, 0}); sumc += c; } int m; cin >> m; for (int i = 0; i < m; ++i) { int c, f, v; cin >> c >> f >> v; a.push_back({-c, f, v, 1}); } sort(a.begin(), a.end(), [](array<int, 4> x, array<int, 4> y) { if (x[1] != y[1]) return x[1] > y[1]; return x[2] < y[2]; }); const long long INF = 2e18; vector<long long> dp(sumc + 1, -INF); dp[0] = 0; for (auto [c, f, v, ignored]: a) { vector<long long> cur = dp; for (int w = 0; w <= sumc; ++w) { int req = w - c; if (req < 0 || req > sumc) continue; if (dp[req] == -INF) continue; cur[w] = max(cur[w], dp[req] + v); } swap(dp, cur); } cout << *max_element(dp.begin(), dp.end()); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:30:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |   for (auto [c, f, v, ignored]: a) {
      |             ^
#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...