제출 #740463

#제출 시각아이디문제언어결과실행 시간메모리
740463kirakaminski968Cloud Computing (CEOI18_clo)C++17
100 / 100
824 ms2128 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct in{ int rate, cores, price; }; bool cmp(in x, in y){ return x.rate != y.rate ? x.rate > y.rate : x.price < y.price; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; vector<in> inputs; int corenum = 0; for(int i = 0;i<N;++i){ int c,f,v; cin >> c >> f >> v; corenum += c; inputs.push_back({f,c,-v}); } int M; cin >> M; for(int i = 0;i<M;++i){ int c,f,v; cin >> c >> f >> v; inputs.push_back({f,-c,v}); } sort(inputs.begin(),inputs.end(),cmp); vector<ll> dp(corenum+1,INT64_MIN); dp[0] = 0; for(auto p : inputs){ vector<ll> answer(dp); for(int i = 0;i<=corenum;++i){ int prev = i-p.cores; if(prev >= 0 && prev <= corenum && dp[prev] != INT64_MIN){ answer[i] = max(answer[i],dp[prev]+p.price); } } dp = answer; } cout << *max_element(dp.begin(),dp.end()); 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...