제출 #1037230

#제출 시각아이디문제언어결과실행 시간메모리
1037230vjudge1Cloud Computing (CEOI18_clo)C++17
0 / 100
1 ms604 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define int long long signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> c(n),f(n),v(n); vector<tuple<int,int,int>> a; int cnt=0; for(int i=0;i<n;i++){ cin >> c[i] >> f[i] >> v[i]; a.push_back({f[i],c[i],v[i]}); cnt += c[i]; } int m; cin >> m; vector<int> C(m),F(m),V(m); for(int i=0;i<m;i++){ cin >> C[i] >> F[i] >> V[i]; a.push_back({F[i],-C[i],-V[i]}); } sort(a.rbegin(),a.rend()); vector<int> dp(cnt+1,-10000000000000); dp[0] = 0; for(auto [i,j,k] : a){ if(k < 0){ for(int l=j;l<=cnt;l++){ dp[l-j] = max(dp[l+j],dp[l]-k); } } else{ for(int l=cnt-j;l>=0;l--){ dp[l+j] = max(dp[l+j],dp[l]-k); } } } sort(dp.rbegin(),dp.rend()); cout << dp[0] << "\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...