# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111244 | KALARRY | Cloud Computing (CEOI18_clo) | C++14 | 2683 ms | 262144 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.
//chockolateman
#include<bits/stdc++.h>
using namespace std;
long long N,M,dp[255][255][255]; //dp[i][j][x] = max_profit if for first i profit and first j orders and purchasing x offers >= f[j]
struct Offer
{
long long c,f,v;
bool operator < (const Offer &Other)
{
return f < Other.f;
}
}offers[2005];
struct Order
{
long long c,f,v;
bool operator < (const Order &Other)
{
return f < Other.f;
}
}orders[2005];
int main()
{
scanf("%lld",&N);
long long total = 0;
for(long long c,f,v,i = 1 ; i <= N ; i++)
{
scanf("%lld%lld%lld",&c,&f,&v);
offers[i] = {c,f,v};
total += c;
}
scanf("%lld",&M);
for(long long c,f,v,i = 1 ; i <= M ; i++)
{
scanf("%lld%lld%lld",&c,&f,&v);
orders[i] = {c,f,v};
}
sort(offers+1,offers+N+1);
sort(orders+1,orders+M+1);
for(long long j = 1 ; j <= M ; j++)
for(long long x = 0 ; x <= total ; x++)
{
dp[0][j][x] = dp[0][j-1][x];
if(x >= orders[j].c)
dp[0][j][x] = max(dp[0][j][x],dp[0][j-1][x - orders[j].c] + orders[j].v);
}
for(long long i = 1 ; i <= N ; i++)
for(long long j = 1 ; j <= M ; j++)
for(long long x = 0 ; x <= total ; x++)
{
dp[i][j][x] = max(dp[i-1][j][x],dp[i][j-1][x]);
if(offers[i].f >= orders[j].f)
dp[i][j][x] = max(dp[i][j][x],dp[i-1][j][x + offers[i].c] - offers[i].v);
}
printf("%lld\n",dp[N][M][0]);
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... |