Submission #656521

#TimeUsernameProblemLanguageResultExecution timeMemory
656521MarcosPauloEversCloud Computing (CEOI18_clo)C++17
54 / 100
1084 ms2444 KiB
#include <bits/stdc++.h> #define int long long using namespace std; struct Item { int f, c, v; }; const int MAXN = 2010, MAXC = 60; int n, m; int dp[MAXN * MAXC][2]; vector<Item> item; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0, c, f, v; i < n; i++) cin >> c >> f >> v, item.push_back({f, c, -v}); cin >> m; for (int i = 0, c, f, v; i < m; i++) cin >> c >> f >> v, item.push_back({f, -c, v}); sort(begin(item), end(item), [](Item i, Item j){ return make_tuple(-i.f, i.c, i.v) < make_tuple(-j.f, j.c, j.v); }); memset(dp, 0xbf, sizeof(dp)); dp[0][0] = dp[0][1] = 0; for (int i = 0; i < n + m; i++) { for (int j = 0; j < MAXN * MAXC; j++) dp[j][i&1] = dp[j][(i&1)^1]; for (int j = max(0ll, item[i].c); j < min(MAXN * MAXC, MAXN * MAXC + item[i].c); j++) dp[j][i&1] = max(dp[j][i&1], item[i].v + dp[j - item[i].c][(i&1)^1]); } int ans = 0, w; for (int i = 0; i < MAXN * MAXC; i++) ans = max(ans, dp[i][((n + m)&1)^1]); cout << ans << "\n"; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:39:15: warning: unused variable 'w' [-Wunused-variable]
   39 |  int ans = 0, w;
      |               ^
#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...