제출 #580373

#제출 시각아이디문제언어결과실행 시간메모리
580373amunduzbaevCloud Computing (CEOI18_clo)C++17
0 / 100
166 ms1952 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef int64_t ll; #define int ll const int inf = 1e18; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<ar<int, 2>> a(n); for(int i=0;i<n;i++){ cin>>a[i][0]>>a[i][1]>>a[i][1]; } int m; cin>>m; vector<ar<int, 2>> b(m); for(int i=0;i<m;i++){ cin>>b[i][0]>>b[i][1]>>b[i][1]; } sort(a.begin(), a.end(), [&](auto& a, auto& b){ return a[1] < b[1]; }); sort(b.begin(), b.end(), [&](auto& a, auto& b){ return a[1] < b[1]; }); vector<int> dp(n * 50 + 1, inf), tp(m * 50 + 1); dp[0] = 0; for(auto x : a){ for(int i=n*50-x[0];~i;i--){ dp[i + x[0]] = min(dp[i + x[0]], dp[i] + x[1]); } } for(auto x : b){ for(int i=m*50-x[0];~i;i--){ tp[i + x[0]] = max(tp[i + x[0]], tp[i] + x[1]); } } for(int i=n*50-1;~i;i--){ dp[i] = min(dp[i], dp[i + 1]); } int res = 0; for(int i=0;i<=m*50;i++){ res = max(res, tp[i] - dp[i]); } cout<<res<<"\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...