이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |