#include <bits/stdc++.h>
using namespace std;
const int N=100001;
int64_t n,c,f,v,dp[N];
vector<array<int64_t,4>>a;
main(){
for(int t:{-1,1}){
cin>>n;
while(n--) cin>>c>>f>>v,a.push_back({-f,t,c*t,v*t});
}
sort(begin(a),end(a));fill(dp+1,dp+N,-2e18);
for(auto [f,t,c,v]:a)
for(int j=t>0?0:N-1;t>0?j+c<N:j>=-c;j+=t)
dp[j]=max(dp[j],dp[j+c]+v);
cout<<*max_element(dp,dp+N);
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# | 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... |