제출 #898297

#제출 시각아이디문제언어결과실행 시간메모리
898297votranngocvyCloud Computing (CEOI18_clo)C++14
0 / 100
1 ms464 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define piii pair<int,pair<int,int>> #define fi first #define se second const int N = 2e3 + 5; const int inf = 0x3f3f3f3f3f3f3f3f; vector<piii>vec; vector<int>dp_before(105,-inf),dp_cur(105,-inf); signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { int c,f,v; cin >> c >> f >> v; vec.push_back({f,{c,-v}}); } int m; cin >> m; for (int i = 1; i <= m; i++) { int c,f,v; cin >> c >> f >> v; vec.push_back({f,{-c,v}}); } sort(vec.begin(),vec.end(),greater<piii>()); dp_before[0] = 0; for (int i = 0; i < (int)vec.size(); i++) { dp_cur = dp_before; for (int j = 0; j <= 50; j++) { if (dp_before[j] == -inf) continue; int newCnt = j + vec[i].se.fi,newCost = dp_before[j] + vec[i].se.se; if (newCnt >= 0) dp_cur[newCnt] = max(dp_cur[newCnt],newCost); } dp_before = dp_cur; } int ans = 0; for (auto x: dp_before) ans = max(ans,x); cout << ans << "\n"; }
#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...