제출 #728544

#제출 시각아이디문제언어결과실행 시간메모리
728544kirakaminski968Cloud Computing (CEOI18_clo)C++17
100 / 100
784 ms2004 KiB
#include <bits/stdc++.h> using namespace std; struct action{ int core, clock, price; }; bool cmp(action a, action b){ return a.clock != b.clock ? a.clock > b.clock : a.price < b.price; } int main() { int n,m; cin >> n; int num = 0; vector<action> inputs; for(int i = 0;i<n;++i){ int a,b,c; cin >> a >> b >> c; inputs.push_back({a,b,-c}); num += a; } cin >> m; for(int i = 0;i<m;++i){ int a,b,c; cin >> a >> b >> c; inputs.push_back({-a,b,c}); } sort(inputs.begin(),inputs.end(),cmp); vector<long long> answers(num+1, INT64_MIN); answers[0] = 0; for (const action &ac : inputs) { vector<long long> newm(answers); for(int cur = 0; cur<=num;++cur){ int prev = cur-ac.core; if (0 <= prev && prev <= num && answers[prev] != INT64_MIN) { newm[cur] = max(newm[cur], answers[prev]+ac.price); } } answers = newm; } cout << *max_element(answers.begin(), answers.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...