Submission #1049280

#TimeUsernameProblemLanguageResultExecution timeMemory
1049280Hamed_GhaffariCloud Computing (CEOI18_clo)C++17
100 / 100
336 ms2788 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<long long, long long>; using ull = unsigned long long; #define X first #define Y second #define SZ(x) int(x.size()) #define all(x) x.begin(), x.end() #define mins(a,b) (a = min(a,b)) #define maxs(a,b) (a = max(a,b)) #define pb push_back #define Mp make_pair #define lc id<<1 #define rc lc|1 #define mid ((l+r)/2) mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll INF = 1e18; const ll MOD = 1e9 + 7; const int MXN = 4e3+5; const int LOG = 23; int n, m; struct item { int c, f, v, z; friend bool operator<(item &i1, item &i2) { return i1.f!=i2.f ? i1.f<i2.f : i1.z<i2.z; } } A[MXN]; vector<ll> dp[2]; void Main() { cin >> n; for(int i=1; i<=n; i++) { cin >> A[i].c >> A[i].f >> A[i].v; A[i].z = +1; } cin >> m; for(int i=n+1; i<=n+m; i++) { cin >> A[i].c >> A[i].f >> A[i].v; A[i].z = -1; } n += m; sort(A+1, A+n+1); dp[(n&1)^1] = {0}; for(int i=n; i>=1; i--) { dp[i&1] = dp[(i&1)^1]; for(int j=0; j<A[i].z*A[i].c; j++) dp[i&1].pb(-INF); for(int j=0; j<SZ(dp[(i&1)^1]); j++) if(0<=j+A[i].c*A[i].z) maxs(dp[i&1][j+A[i].c*A[i].z], dp[(i&1)^1][j]-A[i].z*A[i].v); } cout << *max_element(all(dp[1])) << '\n'; } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int T = 1; // cin >> T; while(T--) Main(); 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...