제출 #483367

#제출 시각아이디문제언어결과실행 시간메모리
483367BERNARB01Cloud Computing (CEOI18_clo)C++17
100 / 100
466 ms2124 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, s = 0; cin >> n; vector<array<int, 4>> a(n); for (int i = 0; i < n; i++) { int c, f, v; cin >> c >> f >> v; a[i] = {-f, 0, c, -v}; s += c; } cin >> m; a.resize(n + m); for (int i = 0; i < m; i++) { int c, f, v; cin >> c >> f >> v; a[i + n] = {-f, 1, -c, v}; } sort(a.begin(), a.end()); const long long inf = (long long) 1e18L; vector<long long> dp(s + 51, -inf); dp[0] = 0; vector<long long> pd(s + 51); for (int i = 0; i < n + m; i++) { int c = a[i][2], v = a[i][3]; pd = dp; for (int j = max(c, 0); j <= s; j++) { pd[j] = max(pd[j], dp[j - c] + v); } swap(dp, pd); } 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...