이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |