제출 #906470

#제출 시각아이디문제언어결과실행 시간메모리
906470belgianbotCloud Computing (CEOI18_clo)C++14
0 / 100
189 ms1712 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); 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 || j + vec[i].c > 50 * N) 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...