# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
318943 | Dymo | Cloud Computing (CEOI18_clo) | C++14 | 544 ms | 2276 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 pb push_back
#define eb emplace_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=1e5+54;
const ll mod =1e9+7 ;
const ll base=1e18;
ll dp[3][maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("t.txt", "r"))
{
freopen("test.txt", "r", stdin);
// freopen("team.out", "w", stdout);
}
ll n, m;
cin>> n ;
vector<pair<ll,pll>> vt;
for (int i=1;i<=n;i++)
{
ll c,f, v;
cin>> c>> f>> v;
v=-v;
vt.pb(make_pair(f,make_pair(c,v)));
}
cin>>m;
for (int i=1;i<=m;i++)
{
ll c, f, v;
cin>> c>> f>> v;
c=-c;
vt.pb(make_pair(f,make_pair(c,v)));
}
for (int i=0;i<maxn;i++)
{
dp[0][i]=dp[1][i]=-1e15;
}
dp[0][0]=0;
sort(vt.rbegin(),vt.rend());
ll cnt=0;
for (auto p:vt)
{
cnt++;
ll now=cnt%2;
ll pre=1-now;
ll cst=p.ss.ss;
ll num=p.ss.ff;
for (int i=0;i<maxn;i++)
{
dp[now][i]=dp[pre][i];
if (i-num<maxn&&i-num>=0)
{
dp[now][i]=max(dp[now][i],dp[pre][i-num]+cst);
}
}
}
ll ans=0;
for (int i=0;i<maxn;i++)
{
ans=max(ans,dp[cnt%2][i]);
}
cout <<ans;
}
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... |