Submission #759433

#TimeUsernameProblemLanguageResultExecution timeMemory
759433AloraCloud Computing (CEOI18_clo)C++17
18 / 100
6 ms1680 KiB
#include <bits/stdc++.h> #define name "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define ft first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define pb push_back #define maxn 2003 using namespace std; int n, m; struct dl{ int c, f, v; bool operator < (const dl &o) const { if(f == o.f) return v > o.v; return f < o.f; } }a[maxn], b[maxn]; int nc, mc, nv, mv, nf, mf; ll res, dp[maxn][maxn]; void sub3(){ sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); fi(i, 1, n){ fi(j, 1, m) if(a[i].f >= b[j].f){ int money = b[j].v - a[i].v; if(money <= 0) continue; // tinh dp[i][j] tu i - 1 hoac j - 1 fi(u, 0, i - 1) dp[i][j] = max(dp[i][j], dp[u][j - 1] + money); // fi(u, 0, j - 1) dp[i][j] = max(dp[i][j], dp[i - 1][u] + money); // cap nhat len dp[i][u] & dp[u][j]; fi(u, j + 1, m) dp[i][u] = max(dp[i][u], dp[i][j]); //fi(u, i + 1, n) dp[u][i] = max(dp[u][j], dp[i][j]); } } fi(i, 1, n) fi(j, 1, m) res = max(res, dp[i][j]); cout << res; exit(0); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); // freopen(name".in", "r", stdin); // freopen(name".out", "w", stdout); cin >> n; fi(i, 1, n){ int c, f, v; cin >> c >> f >> v; a[i] = {c, f, v}; nc = max(nc, c); nf = max(nf, f); nv = max(nv, v); } cin >> m; fi(i, 1, m){ int c, f, v; cin >> c >> f >> v; b[i] = {c, f, v}; mc = max(mc, c); mf = max(mf, f); mv = max(mv, v); } if(n <= 250 && m <= 250 && nc == 1 && mc == 1) sub3(); }
#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...