제출 #580374

#제출 시각아이디문제언어결과실행 시간메모리
580374amunduzbaevCloud Computing (CEOI18_clo)C++17
18 / 100
404 ms2104 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef int64_t ll; #define int ll const int inf = 1e18; const int N = 2005; const int M = 55; 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 * M + 1, inf), tp(N * M + 1); dp[0] = 0; for(auto x : a){ for(int i=N*M-x[0];~i;i--){ dp[i + x[0]] = min(dp[i + x[0]], dp[i] + x[1]); } } for(auto x : b){ for(int i=N*M-x[0];~i;i--){ tp[i + x[0]] = max(tp[i + x[0]], tp[i] + x[1]); } } for(int i=N * M - 1;~i;i--){ dp[i] = min(dp[i], dp[i + 1]); } int res = 0; for(int i=0;i<=N * M;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...