# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165396 | Lawliet | Cloud Computing (CEOI18_clo) | C++14 | 520 ms | 2040 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;
typedef pair<int,int> pii;
typedef long long int lli;
const int MAXS = 50*2000 + 10;
const lli INF = 1000000000000000000LL;
int n, m;
lli dp[MAXS][2];
int main()
{
scanf("%d",&n);
for(int i = 1 ; i < MAXS ; i++)
{
dp[i][0] = INF;
dp[i][1] = -INF;
}
for(int i = 1 ; i <= n ; i++)
{
int c, f, v;
scanf("%d %d %d",&c,&f,&v);
for(int j = MAXS - 1 ; j >= c ; j--)
dp[ j ][0] = min( dp[ j - c ][0] + v , dp[ j ][0] );
}
scanf("%d",&m);
for(int i = 1 ; i <= m ; i++)
{
int c, f, v;
scanf("%d %d %d",&c,&f,&v);
for(int j = MAXS - 1 ; j >= c ; j--)
dp[ j ][1] = max( dp[ j - c ][1] + v , dp[ j ][1] );
}
lli ans = 0;
lli mn = INF;
for(int i = MAXS - 1 ; i >= 0 ; i--)
{
mn = min( mn , dp[i][0] );
ans = max( ans , dp[i][1] - mn );
}
printf("%lld\n",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... |