# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441678 | linkret | Cloud Computing (CEOI18_clo) | C++14 | 763 ms | 1944 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std; long long int dp [2][2010*50];
struct rac {
int f, ku, v;
};
vector < rac > k;
int cmp (rac a, rac b){
if (a.f==b.f){
if (a.ku>b.ku) return 1;
return 0;
}
if (a.f>b.f) return 1;
return 0;
}
int main(){
int n,m; cin >> n;
for (int i=0; i<n; i++) {
int c,f,v; cin >> c >> f >> v; v=(-v);
rac x; x.ku=c; x.f=f; x.v=v;
k.push_back(x);
}
cin >> m;
for (int i=0; i<m; i++) {
int c,f,v; cin >> c >> f >> v; c=(-c);
rac x; x.ku=c; x.f=f; x.v=v;
k.push_back(x);
}
long long int sol=0;
sort (k.begin(), k.end(), cmp);
for (int j=1; j<2010*50; j++) dp[0][j]=-1e9;
for (int i=0; i<k.size(); i++) {
for (int j=0; j<2010*50; j++) {
if (j<k[i].ku) dp[1][j]=dp[0][j];
else if (j-k[i].ku>=2010*50) dp[1][j]=dp[0][j];
else dp [1][j] = max (dp[0][j-k[i].ku]+k[i].v, dp[0][j]);
}
for (int j=0; j<2010*50; j++) dp[0][j]=dp[1][j];
}
for (int j=0; j<2010*50; j++) sol=max (sol, dp[0][j]);
cout << sol;
return 0;
}
Compilation message (stderr)
# | 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... |