제출 #965553

#제출 시각아이디문제언어결과실행 시간메모리
965553Charizard2021Cloud Computing (CEOI18_clo)C++17
100 / 100
856 ms2392 KiB
#include<bits/stdc++.h> using namespace std; struct Object{ int c, f, v; bool operator< (const Object& o) const{ return (f == o.f && v < o.v) || (f > o.f); } }; int main(){ int n; cin >> n; vector<Object> objects; for(int i = 0; i < n; i++){ int c, f, v; cin >> c >> f >> v; objects.push_back({c, f, -v}); } int m; cin >> m; for(int i = 0; i < m; i++){ int c, f, v; cin >> c >> f >> v; objects.push_back({-c, f, v}); } sort(objects.begin(), objects.end()); vector<long long> dp(100001, -1e14); dp[0] = 0; for(int i = 0; i < n + m; i++){ vector<long long> ndp(100001, -1e14); ndp[0] = 0; for(int c = 0; c <= 100000; c++){ if(c - objects[i].c <= 100000 && objects[i].c <= c){ ndp[c] = max(ndp[c], dp[c - objects[i].c] + objects[i].v); } } for(int c = 0; c <= 100000; c++){ dp[c] = max(dp[c], ndp[c]); } } long long maxVal = -1e14; for(int i = 0; i <= 100000; i++){ maxVal = max(maxVal, dp[i]); } cout << maxVal << "\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...