# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667569 | Augustyn | Cloud Computing (CEOI18_clo) | C++14 | 300 ms | 1208 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 takt first
#define cena second.first
#define ilerdz second.second
int n,m,lacz_rdz,najw_rdz;
pair<int,pair<int,int>>je_kalk[2001],klient[2001];
long long dp[100001];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d%d%d",&je_kalk[i].ilerdz,&je_kalk[i].takt,&je_kalk[i].cena);
lacz_rdz+=je_kalk[i].ilerdz;
}
scanf("%d",&m);
for(int i=1;i<=m;++i)
{
scanf("%d%d%d",&klient[i].ilerdz,&klient[i].takt,&klient[i].cena);
}
sort(je_kalk+1,je_kalk+n+1);
sort(klient+1,klient+m+1);
for(int i=1;i<=lacz_rdz;++i)
dp[i]=LONG_LONG_MIN;
while(m)
{
while(n)
{
if(je_kalk[n].takt<klient[m].takt)
break;
for(int i=najw_rdz+je_kalk[n].ilerdz;i>=je_kalk[n].ilerdz;--i)
{
if(dp[i-je_kalk[n].ilerdz]!=LONG_LONG_MIN)
dp[i]=max(dp[i],dp[i-je_kalk[n].ilerdz]-je_kalk[n].cena);
}
najw_rdz+=je_kalk[n].ilerdz;
--n;
}
for(int i=0;i<=najw_rdz-klient[m].ilerdz;++i)
{
if(dp[i+klient[m].ilerdz]!=LONG_LONG_MIN)
dp[i]=max(dp[i],dp[i+klient[m].ilerdz]+klient[m].cena);
}
--m;
}
long long odp=0;
for(int i=0;i<=lacz_rdz;++i)
odp=max(odp,dp[i]);
printf("%lld",odp);
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... |