Submission #133276

#TimeUsernameProblemLanguageResultExecution timeMemory
133276MinnakhmetovCloud Computing (CEOI18_clo)C++14
18 / 100
409 ms2328 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() const int N = 2005, S = 1e5 + 5; const ll INF = 1e18; struct C { int c, f, v; bool operator < (const C &oth) const { return f < oth.f; } } a[N], b[N]; ll sum[S], dp[S]; int freq[S]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].c >> a[i].f >> a[i].v; } cin >> m; for (int i = 0; i < m; i++) { cin >> b[i].c >> b[i].f >> b[i].v; } sort(a, a + n); sort(b, b + m); int s = 0; for (int i = 0; i < n; i++) { sum[s + 1] = a[i].v; for (int j = 0; j < a[i].c; j++) { freq[j + s + 1] = a[i].f; } s += a[i].c; } for (int i = 1; i <= s; i++) { sum[i] += sum[i - 1]; } fill(dp, dp + S, -INF); for (int i = 0; i < s; i++) { if (sum[i] != sum[i + 1]) { dp[i] = 0; } } for (int i = 0; i < m; i++) { for (int j = s - b[i].c; j >= 0; j--) { if (freq[j + 1] < b[i].f) break; dp[j + b[i].c] = max(dp[j + b[i].c], dp[j] + b[i].v - sum[j + b[i].c] + sum[j]); } ll mx = 0; for (int j = 0; j < s; j++) { if (sum[j] != sum[j + 1]) dp[j] = max(dp[j], mx); mx = max(mx, dp[j]); } } cout << *max_element(dp, dp + s + 1); 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...