Submission #133353

#TimeUsernameProblemLanguageResultExecution timeMemory
133353MinnakhmetovCloud Computing (CEOI18_clo)C++14
54 / 100
1448 ms2268 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, K = 105; 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 dp[N][K]; void upd(ll &a, ll b) { a = max(a, b); } 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); for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { dp[i][j] = -INF; } } dp[0][0] = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (b[i].f <= a[j].f) { for (int k = a[j].c - 1; k >= 0; k--) { upd(dp[j][k + b[i].c], dp[j][k] + b[i].v); } } } for (int j = 0; j < n; j++) { for (int k = 0; k < K; k++) { upd(dp[j + 1][k], dp[j][k]); upd(dp[j + 1][max(0, k - a[j].c)], dp[j][k] - a[j].v); } } } cout << dp[n][0]; 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...