제출 #540284

#제출 시각아이디문제언어결과실행 시간메모리
540284UncoolAnonCloud Computing (CEOI18_clo)C++14
100 / 100
1102 ms2132 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define sz(a) ((int)a.size()) using namespace std; const int N=100010,bal=20,inf=(1LL<<60); signed main(){ int n; cin>>n; vector<int> c,f,v; vector<int> index; for(int i=0;i<n;i++){ int ci,fi,vi; cin>>ci>>fi>>vi; c.pb(ci); f.pb(fi); v.pb(vi*-1); index.push_back(i); } int m; cin>>m; for(int i=0;i<m;i++){ int ci,fi,vi; cin>>ci>>fi>>vi; index.push_back(sz(c)); c.pb(ci*-1);f.pb(fi); v.pb(vi); } sort(index.begin(),index.end(),[&](int a,int b){if(f[a]==f[b]) return c[a]>c[b]; return f[a]>f[b]; }); vector<int> dp(N,-inf); dp[0]=0; int answer=0; for(int i:index){ vector<int> ndp=dp; for(int value=0;value<N;value++) if(value-c[i]<N&&value-c[i]>=0) ndp[value]=max(dp[value-c[i]]+v[i],ndp[value]); dp=ndp; for(int value=0;value<N;value++) answer=max(answer,dp[value]); } cout<<answer; 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...