Submission #598291

#TimeUsernameProblemLanguageResultExecution timeMemory
5982911binCloud Computing (CEOI18_clo)C++14
100 / 100
439 ms1364 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int MAX = 1e5 + 5; struct t{ ll c, f, p, op; bool operator <(const t & x){ if(f == x.f) return p < x.p; return f > x.f; } }; ll n, m, c, f, p, dp[MAX]; vector<t> v; int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; while(n--){ cin >> c >> f >> p; v.push_back({c, f, -p, 0LL}); } cin >> m; while(m--){ cin >> c >> f >> p; v.push_back({c, f, p, 1LL}); } sort(all(v)); memset(dp, 0xc1, sizeof(dp)); dp[0] = 0; for(auto& x : v){ if(x.p < 0){ for(int i = MAX - 1; i >= x.c; i--) dp[i] = max(dp[i], dp[i - x.c] + x.p); } else{ for(int i = 0; i + x.c < MAX; i++) dp[i] = max(dp[i], dp[i + x.c] + x.p); } } ll ans = 0; for(int i = 0; i < MAX; i++) ans = max(ans, dp[i]); cout << ans; 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...