Submission #960402

#TimeUsernameProblemLanguageResultExecution timeMemory
960402vjudge1Cloud Computing (CEOI18_clo)C++14
18 / 100
278 ms1432 KiB
#include<bits/stdc++.h> using namespace std; #define int long long struct Computer{ int c, f, v; Computer (int _c=0, int _f=0, int _v=0): c(_c), f(_f), v(_v){} bool operator<(const Computer &b){ return f<b.f; } }; const int N=2010, inf=1e18; int f[N*50]; int n, m; Computer a[N]; vector<pair<int, int>> vv[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i=1; i<=n; ++i) cin >> a[i].c >> a[i].f >> a[i].v; sort(a+1, a+n+1); cin >> m; for (int i=1; i<=m; ++i){ Computer b; cin >> b.c >> b.f >> b.v; if (b.f>a[n].f) continue; vv[lower_bound(a+1, a+n+1, b)-a].emplace_back(b.c, b.v); } for (int i=0; i<N*50; ++i) f[i]=-inf; f[0]=0; for (int i=n; i>=1; --i){ int mx=0; for (int j=(n-i)*50; j>=0; --j) f[j+a[i].c]=max(f[j+a[i].c], f[j]-a[i].v); for (int j=0; j<=(n-i)*50; ++j) if (f[j]!=-inf) mx=j; for (auto &j:vv[i]){ int c=j.first, v=j.second; for (int k=c; k<=mx; ++k) if (f[k]!=-inf) f[k-c]=max(f[k-c], f[k]+v); } } cout << *max_element(f, f+n+1) << '\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...