Submission #906483

#TimeUsernameProblemLanguageResultExecution timeMemory
906483belgianbotCloud Computing (CEOI18_clo)C++14
18 / 100
607 ms2388 KiB
#include <bits/stdc++.h> #define int long long using namespace std; struct a{ int c, f, v; bool operator< (const a &b) const { if (f == b.f) { return (c > b.c); } return (f > b.f); } bool operator> (const a &b) const { if (f == b.f) { return (c < b.c); } return (f < b.f); } }; int N, M; vector<a> vec; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i(0); i < N; i++) { a l; cin >> l.c >> l.f >> l.v; l.v *= -1; vec.push_back(l); } cin >> M; for (int i(0); i < M; i++) { a l; cin >> l.c >> l.f >> l.v; l.c *= -1; vec.push_back(l); } sort(vec.begin(), vec.end()); vector <int> dp(N * 50 + 1, INT_MIN), saved(N * 50 + 1, INT_MIN); dp[0] = 0; saved[0] = 0; for (int i(0); i < N + M; i++) { for (int j(0); j < 50 * N + 1; j++) { if (j + vec[i].c < 0) continue; saved[j + vec[i].c] = max(dp[j + vec[i].c], dp[j] + vec[i].v); } dp = saved; } cout << *max_element(dp.begin(), dp.end()) << '\n'; return 0; }
#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...