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