# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870269 | rsjw | Cloud Computing (CEOI18_clo) | C++17 | 566 ms | 2388 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;
#define int long long
tuple<int,int,int> a[4010];
int v[4010],w[4010];
int f[2][100010];
void chmax(int &x,int y) {
x=max(x,y);
}
signed main() {
int n,m,i,j,k,p,u;
cin>>n;
int l=0;
for(i=1; i<=n; i++) cin>>j>>u>>k,a[++l]=make_tuple(-2*u,j,-k);
cin>>m;
for(i=1; i<=m; i++) cin>>j>>u>>k,a[++l]=make_tuple(-2*u+1,-j,k);
sort(a+1,a+l+1);
n=l;
for(i=1; i<=n; i++) {
tie(j,k,u)=a[i];
v[i]=k,w[i]=u;
}
memset(f,0xaf,sizeof(f)); f[0][0]=0;
for(i=0; i<n; i++) {
memset(f[i&1^1],0xaf,sizeof(f[i&1^1]));
for(j=0; j<=100002; j++) {
if(j+v[i+1]>=0) chmax(f[i&1^1][j+v[i+1]],f[i&1][j]+w[i+1]);
chmax(f[i&1^1][j],f[i&1][j]);
}
}
int ans=0;
for(j=0; j<=100002; j++) ans=max(ans,f[n&1][j]);
cout<<ans<<endl;
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... |