이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n;
vector <vector <int> > vec;
for(int i=0;i<n;i++){
int c,f,v;
cin>>c>>f>>v;
vec.pb({f,1,c,v});
}
cin>>m;
for(int i=0;i<m;i++){
int c,f,v;
cin>>c>>f>>v;
vec.pb({f,0,c,v});
}
sort(all(vec));reverse(all(vec));
vector <int> dp(2e5+5,-1e18);
dp[0]=0;
for(int i=0;i<vec.size();i++){
if(vec[i][1]==1){
for(int j=1e5;j>=0;j--)dp[j+vec[i][2]]=max(dp[j+vec[i][2]],dp[j]-vec[i][3]);
}
else{
for(int j=vec[i][2];j<=1e5;j++)dp[j-vec[i][2]]=max(dp[j-vec[i][2]],dp[j]+vec[i][3]);
}
}
int ans=0;
for(int i=0;i<=1e5;i++)ans=max(ans,dp[i]);
cout<<ans<<"\n";
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0;i<vec.size();i++){
| ~^~~~~~~~~~~
# | 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... |