Submission #795667

#TimeUsernameProblemLanguageResultExecution timeMemory
795667Trisanu_DasCloud Computing (CEOI18_clo)C++17
100 / 100
526 ms2024 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, x, y) for (int i = x; i < y; i++) #define mx (int)1e5+5 #define ll long long struct CP{ int c; ll f, v; }; int main(){ int n, m; CP A[4005]; array<ll, mx> dp; cin >> n; FOR(i, 0, n) cin >> A[i].c >> A[i].f >> A[i].v, A[i].v *= -1; cin >> m; FOR(i, n, m+n) cin >> A[i].c >> A[i].f >> A[i].v, A[i].c *= -1; sort(A, A+n+m, [](CP a, CP b){ return (a.f > b.f) or (a.f == b.f and a.c > b.c); } ); dp.fill(-1e18); dp[0] = 0; FOR(i, 0, m+n){ array<ll, mx> DP; FOR(j, 0, mx){ DP[j] = dp[j]; if (j-A[i].c < 0 or j-A[i].c >= mx) continue; DP[j] = max(DP[j], dp[j-A[i].c]+A[i].v); }dp = DP; }cout<<*max_element(dp.begin(), dp.end())<<endl; }
#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...