이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct ComputersAndOrders{
int cores;
int clockSpeed;
int price;
};
int n, m;
vector<ComputersAndOrders> computersAndOrders;
bool decreaseF(const ComputersAndOrders a, const ComputersAndOrders b){
if(a.clockSpeed == b.clockSpeed){
if(a.price==b.price){
return a.price > b.price;
}
return a.cores > b.cores;
}
return a.clockSpeed > b.clockSpeed;
}
int DP(){
vector<int> memo(1e5, -1e15);
vector<int> mem;
memo[0]=0;
mem.assign(memo.begin(), memo.end());
for(int i = 0; i < n+m; i++){
for(int j = 0; j < 1e5; j++){
if(memo[j] > -1e15 && j+computersAndOrders[i].cores>0){
mem[j+computersAndOrders[i].cores] = max(memo[j+computersAndOrders[i].cores], memo[j]+computersAndOrders[i].price);
}
}
memo.clear();
memo.assign(mem.begin(), mem.end());
}
int ans = 0;
for(int i = 0; i < 1e5; i++){
ans = max(ans, memo[i]);
}
return ans;
}
signed main(){
cin >> n;
computersAndOrders.resize(n);
int c, f, v;
for(int i = 0; i <n; i++){
cin >> c >> f >> v;
computersAndOrders[i].cores = c;
computersAndOrders[i].clockSpeed = f;
computersAndOrders[i].price = -v;
}
cin >> m;
computersAndOrders.resize(n+m);
for(int i = 0; i < m; i++){
cin >> c >> f >> v;
computersAndOrders[i+n].cores = -c;
computersAndOrders[i+n].clockSpeed = f;
computersAndOrders[i+n].price = v;
}
sort(computersAndOrders.begin(), computersAndOrders.end(), decreaseF);
cout << DP() << "\n";
}
# | 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... |