이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=1e5+5;
const int INF=1e9;
const int MOD=1e9+7;
const int MAXL=61;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//cout<<setprecision(6)<<fixed;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n,m;
cin>>n;
vector<vector<int>>info; //freq, -delta profit, delta core
for(int i=0;i<n;i++) {
int c,f,v;
cin>>c>>f>>v;
info.push_back({f,v,c});
}
cin>>m;
for(int i=0;i<m;i++) {
int c,f,v;
cin>>c>>f>>v;
info.push_back({f,-v,-c});
}
sort(info.begin(),info.end(),greater<vector<int>>());
int dp[MAX][2];
for(int i=1;i<MAX;i++) {
dp[i][1]=-INF;
}
dp[0][1]=0;
int curr=0;
for(int i=0;i<info.size();i++) {
for(int j=0;j<MAX;j++) {
dp[j][curr]=dp[j][curr^1];
if(j-info[i][2]>=0 && j-info[i][2]<MAX) {
dp[j][curr]=max(dp[j][curr],dp[j-info[i][2]][curr^1]-info[i][1]);
}
}
curr^=1;
}
curr^=1;
int ans=0;
for(int i=0;i<MAX;i++) {
ans=max(ans,dp[i][curr]);
}
cout<<ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:36: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]
36 | for(int i=0;i<info.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... |