Submission #596035

#TimeUsernameProblemLanguageResultExecution timeMemory
596035HanksburgerCloud Computing (CEOI18_clo)C++17
100 / 100
584 ms1928 KiB
#include <bits/stdc++.h> using namespace std; pair<pair<int, int>, int> a[4005]; long long dp[100005], tmp[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n; for (int i=1; i<=n; i++) { cin >> a[i].first.second >> a[i].first.first >> a[i].second; a[i].second*=-1; } cin >> m; for (int i=n+1; i<=n+m; i++) { cin >> a[i].first.second >> a[i].first.first >> a[i].second; a[i].first.second*=-1; } sort(a+1, a+n+m+1, greater<pair<pair<int, int>, int> >()); for (int i=1; i<=1e5; i++) dp[i]=-1e18; for (int i=1; i<=n+m; i++) { for (int j=0; j<=1e5; j++) { if (j-a[i].first.second>=0 && j-a[i].first.second<=1e5) tmp[j]=max(dp[j], dp[j-a[i].first.second]+a[i].second); else tmp[j]=dp[j]; } for (int j=0; j<=1e5; j++) dp[j]=tmp[j]; } long long ans=0; for (int i=0; i<=1e5; i++) ans=max(ans, dp[i]); cout << ans; 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...