제출 #1306353

#제출 시각아이디문제언어결과실행 시간메모리
1306353namhhCloud Computing (CEOI18_clo)C++20
100 / 100
235 ms1476 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define fi first #define se second const int N = 1e5+5; int n,m,dit[N]; struct loz{ int id,c,f,v; }; vector<loz>cak; bool cmp(loz a, loz b){ if(a.f == b.f) return a.id < b.id; return a.f > b.f; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 1; i <= n; i++){ int c,f,v; cin >> c >> f >> v; cak.push_back({-1,c,f,v}); } cin >> m; for(int i = 1; i <= m; i++){ int c,f,v; cin >> c >> f >> v; cak.push_back({1,c,f,v}); } sort(cak.begin(),cak.end(),cmp); for(int i = 1; i <= 100000; i++) dit[i] = -1e18; for(auto[id,c,f,v]: cak){ if(id == -1){ for(int i = 100000; i >= c; i--) dit[i] = max(dit[i],dit[i-c]-v); } else{ for(int i = 0; i <= 100000-c; i++) dit[i] = max(dit[i],dit[i+c]+v); } } int ans = 0; for(int i = 0; i <= 100000; i++) ans = max(ans,dit[i]); cout << ans; }
#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...