Submission #1268294

#TimeUsernameProblemLanguageResultExecution timeMemory
1268294sun2305Cloud Computing (CEOI18_clo)C++20
100 / 100
631 ms2120 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pll pair<ll,ll> #define maxn 2005 #define task "DATPHONG" using namespace std; ll n,m,sum,ans; const ll inf=1e18; struct dt{ll c,f,v;}; vector<dt> st; bool cmp(dt a, dt b){ if(a.f==b.f) return a.v<b.v; return a.f>b.f; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin>>n; for(ll i=1; i<=n; i++){ ll c,f,v; cin>>c>>f>>v; sum+=c; st.push_back({c,f,-v}); } cin>>m; for(ll i=1; i<=m; i++){ ll c,f,v; cin>>c>>f>>v; st.push_back({-c,f,v}); } sort(st.begin(), st.end(), cmp); vector<ll> f(sum+5, -inf); f[0]=0; for(dt x:st){ vector<ll> g(f); for(ll j=0; j<=sum; j++){ if(x.c<=j and j-x.c<=sum and f[j-x.c]!=-inf) g[j]=max(g[j], f[j-x.c]+x.v); } f=g; } for(ll i=0; i<=sum; i++) ans=max(ans, f[i]); cout<<ans; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
clo.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...