제출 #858758

#제출 시각아이디문제언어결과실행 시간메모리
858758boyliguanhanCloud Computing (CEOI18_clo)C++17
100 / 100
310 ms1624 KiB
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; #define int long long #define MX 100001 vector<tuple<int, int, int>> v; int dp[MX]; signed main() { memset(dp,-8,sizeof dp); dp[0]=0; int n, m; cin >> n; while(n--) { int a, b, c; cin >> a >> b >> c; v.push_back({b,a,-c}); } cin >> m; while(m--) { int a, b, c; cin >> a >> b >> c; v.push_back({b,-a,c}); } sort(v.begin(),v.end()); reverse(v.begin(),v.end()); for(auto K: v) { int a, b, c; tie(a,b,c)=K; if(b > 0) { for(int i = MX; i-- > b;) dp[i]=max(dp[i],c+dp[i-b]); } else { for(int i = 0; i < MX+b; i++) dp[i]=max(dp[i],c+dp[i-b]); } } cout << *max_element(dp,dp+MX); 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...