제출 #1174911

#제출 시각아이디문제언어결과실행 시간메모리
1174911Dan4LifeCloud Computing (CEOI18_clo)C++20
100 / 100
234 ms1480 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using ar4 = array<ll,4>; const int mxN = (int)2e5+10; const int mxM = 50*2000+2; const ll LINF = (ll)2e18; ll dp[mxM]; vector<ar4> a; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); for(int t:{0,1}){ int n,c,f,v; cin >> n; while(n--) cin>>c>>f>>v, a.pb({c,f,v*(t?1:-1),t}); } sort(all(a),[&](ar4 x, ar4 y){ if(x[1]!=y[1]) return x[1]>y[1]; return x[3]<y[3]; }); fill(dp+1,dp+mxM,-LINF); for(auto [c,f,v,t] : a){ if(!t){ for(int j = mxM-1; j>=c; j--) dp[j] = max(dp[j], dp[j-c]+v); } else{ for(int j = 0; j+c<mxM; j++) dp[j] = max(dp[j], dp[j+c]+v); } } cout << *max_element(dp,dp+mxM) << "\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...