Submission #483418

#TimeUsernameProblemLanguageResultExecution timeMemory
483418A_DCloud Computing (CEOI18_clo)C++14
0 / 100
4 ms1996 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second using namespace std; const int N=2e3+100; vector<int> dp1(N*50); vector<int> dp2(N*50); int c[N],v[N]; int cost[N*50]; int cost2[N*50]; int C[N],V[N]; const int INF=9e18; int n; int m; void solve() { cin>>n; for(int i=1;i<=n;i++){ scanf("%lld%lld%lld",&c[i],&v[i],&v[i]); } cin>>m; for(int i=1;i<=m;i++){ scanf("%lld%lld%lld",&C[i],&V[i],&V[i]); } for(int j=1;j<N*50;j++){ dp1[j]=INF; } for(int i=1;i<=n;i++){ for(int j=1;j<=n*50;j++){ if(j-c[i]>=0){ dp2[j]=dp1[j-c[i]]+v[i]; } dp2[j]=min(dp1[j],dp2[j]); } dp1=dp2; } for(int j=0;j<=n*50;j++){ cost[j]=dp2[j]; } for(int j=1;j<N*50;j++){ dp1[j]=0; } for(int i=1;i<=m;i++){ for(int j=1;j<=m*50;j++){ if(j-C[i]>=0){ dp2[j]=max(dp1[j],dp1[j-C[i]]+V[i]); } else dp2[j]=dp1[j]; dp2[j]=max(dp2[j],dp1[j-1]); // cout<<dp[i][j]<<" "; } // cout<<endl; } // cout<<endl; int mx=0; for(int i=1;i<=n*50;i++){ mx=max(mx,dp2[i]-cost[i]); // cout<<cost[i]<<" "<<dp[m][i]<<endl; } // cout<<endl; cout<<mx<<endl; } main() { // freopen("face.in","r",stdin); // freopen("face.out","w",stdout); int t=1; // cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

clo.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main()
      | ^~~~
clo.cpp: In function 'void solve()':
clo.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%lld%lld%lld",&c[i],&v[i],&v[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld%lld%lld",&C[i],&V[i],&V[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...