# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092203 | quan606303 | Cloud Computing (CEOI18_clo) | C++14 | 4 ms | 1116 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>
#define int long long
#define ll long long
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a))
#define endl '\n'
using namespace std;
struct plinh
{
int sophong,yeucau,tien;
};
plinh hotel[2005],customer[2005];
int n,m;
const int maxw=2000*50;
int dp1[maxw+7],dp2[maxw+7];
void solve()
{
for (int i=1;i<=maxw;i++)dp1[i]=-1e18;
for (int i=1;i<=n;i++)
{
for (int j=maxw;j>=1;j--)
{
if (j-hotel[i].sophong>=0&&dp1[j-hotel[i].sophong]!=-1e18)dp1[j]=max(dp1[j],dp1[j-hotel[i].sophong]-hotel[i].tien);
}
}
for (int i=1;i<=m;i++)
{
for (int j=maxw;j>=1;j--)
{
if (j-customer[i].sophong>=0)dp2[j]=max(dp2[j],dp2[j-customer[i].sophong]+customer[i].tien);
}
}
int ans=0;
for (int i=1;i<=maxw;i++)ans=max(ans,dp2[i]+dp1[i]);
cout<<ans;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("TEST.INP","r",stdin);
freopen("TEST.OUT","w",stdout);
cin>>n;
for (int i=1;i<=n;i++)cin>>hotel[i].sophong>>hotel[i].yeucau>>hotel[i].tien;
cin>>m;
for (int i=1;i<=m;i++)cin>>customer[i].sophong>>customer[i].yeucau>>customer[i].tien;
solve();
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... |