Submission #128110

#TimeUsernameProblemLanguageResultExecution timeMemory
128110TadijaSebezCloud Computing (CEOI18_clo)C++11
100 / 100
681 ms2296 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair const int N=2005; const int K=52; const int M=N*K; const ll inf=1e18; ll dp[2][M]; struct Event { int t,c,f,v; Event(){} Event(int _t, int _c, int _f, int _v):t(_t),c(_c),f(_f),v(_v){} bool operator < (Event b) const { return mp(f,t)>mp(b.f,b.t);} }; vector<Event> evs; int main() { int n,m,c,f,v; scanf("%i",&n); for(int i=1;i<=n;i++) scanf("%i %i %i",&c,&f,&v),evs.pb(Event(1,c,f,v)); scanf("%i",&m); for(int i=1;i<=m;i++) scanf("%i %i %i",&c,&f,&v),evs.pb(Event(0,c,f,v)); int t=1; for(int i=0;i<M;i++) dp[0][i]=dp[1][i]=-inf; dp[t^1][0]=0; sort(evs.begin(),evs.end()); for(Event e:evs) { if(e.t==0) e.c=-e.c; else e.v=-e.v; for(int i=0;i<M;i++) { dp[t][i]=dp[t^1][i]; if(i-e.c>=0 && i-e.c<M) dp[t][i]=max(dp[t][i],dp[t^1][i-e.c]+e.v); } t^=1; } ll ans=0; for(int i=0;i<M;i++) ans=max(ans,dp[t^1][i]); printf("%lld\n",ans); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
clo.cpp:23:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%i %i %i",&c,&f,&v),evs.pb(Event(1,c,f,v));
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&m);
  ~~~~~^~~~~~~~~
clo.cpp:25:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++) scanf("%i %i %i",&c,&f,&v),evs.pb(Event(0,c,f,v));
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...