제출 #858756

#제출 시각아이디문제언어결과실행 시간메모리
858756boyliguanhanCloud Computing (CEOI18_clo)C++17
54 / 100
38 ms812 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 MX 10001 vector<tuple<int, int, int>> v; long long dp[MX]; int 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...