제출 #870738

#제출 시각아이디문제언어결과실행 시간메모리
870738Darren0724Cloud Computing (CEOI18_clo)C++17
100 / 100
322 ms1624 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define int long long #define all(x) x.begin(), x.end() #define x first #define y second const int N=100005; const int INF=1e18; struct qry{ int c,f,v; bool operator<(const qry &o){ return f!=o.f?f>o.f:c>o.c; } }; int32_t main() { LCBorz; int n;cin>>n; vector<qry> v; for(int i=0;i<n;i++){ int a,b,c;cin>>a>>b>>c; v.push_back({a,b,c}); } int m;cin>>m; for(int i=0;i<m;i++){ int a,b,c;cin>>a>>b>>c; v.push_back({-a,b,c}); } sort(all(v)); vector<int> dp(N,-INF); dp[0]=0; for(int i=0;i<n+m;i++){ auto [c,f,val]=v[i]; if(c>0){ for(int j=N-1;j>=c;j--){ dp[j]=max(dp[j],dp[j-c]-val); } } else{ c=-c; for(int j=0;j+c<N;j++){ dp[j]=max(dp[j],dp[j+c]+val); } } } int ans=0; for(int i=0;i<N;i++){ ans=max(ans,dp[i]); } cout<<ans<<endl; 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...