Submission #920150

#TimeUsernameProblemLanguageResultExecution timeMemory
920150Faisal_SaqibCloud Computing (CEOI18_clo)C++17
18 / 100
672 ms3664 KiB
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; const int N=2001; long long c[N],f[N],v[N],C[N],F[N],V[N]; long long buy[N*50][2]; long long sell[N*50][2]; const long long inf=1e14; int main() { int n; cin>>n; for(int i=0;i<n;i++) { cin>>c[i]>>f[i]>>v[i]; } int m; cin>>m; for(int i=0;i<m;i++) { cin>>C[i]>>F[i]>>V[i]; } // when all f=F for(int i=0;i<=(50*n);i++) buy[i][0]=inf; for(int i=0;i<=(50*n);i++) buy[i][1]=inf; buy[0][0]=0; for(int j=0;j<n;j++) { for(int i=0;i<=(50*n);i++) if(buy[i][0]!=inf) buy[i+c[j]][1]=min(buy[i+c[j]][1],buy[i][0]+v[j]); for(int i=0;i<=(50*n);i++) buy[i][0]=min(buy[i][0],buy[i][1]); } for(int i=0;i<=(50*n);i++) sell[i][0]=-inf; for(int i=0;i<=(50*n);i++) sell[i][1]=-inf; sell[0][0]=0; for(int j=0;j<m;j++) { for(int i=0;i<=(50*m);i++) if(sell[i][0]!=-inf) sell[i+C[j]][1]=max(sell[i+C[j]][1],sell[i][0]+V[j]); for(int i=0;i<=(50*n);i++) sell[i][0]=max(sell[i][0],sell[i][1]); } long long ans=0; long long mx=-1e18; for(int i=0;i<=(50*n);i++) { mx=max(mx,sell[i][0]); // if(i<=11) // { // cout<<mx<<' '<<buy[i][0]<<endl; // } ans=max(ans,mx-buy[i][0]); } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...