Submission #712965

#TimeUsernameProblemLanguageResultExecution timeMemory
712965gortomiCloud Computing (CEOI18_clo)C++17
100 / 100
414 ms1264 KiB
#include <bits/stdc++.h> using namespace std; struct val { int c, f, v; }; bool comp(val a, val b) { return a.f > b.f; } long long dp[100001]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n; vector<val> com(n); for(int i = 0; i < n; i++) cin >> com[i].c >> com[i].f >> com[i].v; cin >> m; vector<val> ord(m); for(int i = 0; i < m; i++) cin >> ord[i].c >> ord[i].f >> ord[i].v; sort(com.begin(), com.end(), comp); sort(ord.begin(), ord.end(), comp); fill(dp, dp + 100001, 1e18); dp[0] = 0; int l = 0; while(l < m && ord[l].f > com[0].f) l++; for(auto x : com) { while(l < m && ord[l].f > x.f) { val u = ord[l++]; for(int i = 0; i <= 100000 - u.c; i++) { dp[i] = min(dp[i], dp[i + u.c] - u.v); } } for(int i = 100000; i >= 0; i--) { dp[i] = min(dp[i], dp[max(i - x.c, 0)] + x.v); } } while(l < m) { val u = ord[l++]; for(int i = 0; i <= 100000 - u.c; i++) { dp[i] = min(dp[i], dp[i + u.c] - u.v); } } cout << dp[0] * -1; }
#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...