Submission #754233

#TimeUsernameProblemLanguageResultExecution timeMemory
754233MetalPowerCloud Computing (CEOI18_clo)C++14
18 / 100
33 ms32872 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pli pair<int, pii> #define fi first #define se second const int MX = 2e3 + 10; const int MN = 1e3 + 10; const ll INF = 1e18; int N, M; ll dp[MX][MN]; vector<pli> vec; void chmax(ll& a, ll b){ if(b > a) a = b; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 0; i < N; i++){ int c, f, v; cin >> c >> f >> v; vec.push_back({f, {c, -v}}); } cin >> M; for(int i = 0; i < M; i++){ int c, f, v; cin >> c >> f >> v; vec.push_back({f, {-c, v}}); } int sz = vec.size(); sort(vec.begin(), vec.end(), greater<pli>()); dp[0][0] = 0; for(int j = 1; j < MN; j++) dp[0][j] = -INF; for(int i = 0; i < sz; i++){ for(int j = 0; j < MN; j++){ dp[i + 1][j] = dp[i][j]; int pre = j - vec[i].se.fi; if(MN > pre && pre >= 0) chmax(dp[i + 1][j], dp[i][pre] + vec[i].se.se); } } ll ans = 0; for(int j = 0; j < MN; j++) chmax(ans, dp[sz][j]); cout << ans << '\n'; }
#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...