제출 #483366

#제출 시각아이디문제언어결과실행 시간메모리
483366BERNARB01Cloud Computing (CEOI18_clo)C++17
18 / 100
336 ms1160 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 int inf = (int) 1e9 + 9; vector<int> dp(s + 51, -inf); dp[0] = 0; vector<int> 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...