이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std; long long int dp [2][2010*50];
struct rac {
int f, ku, v;
};
vector < rac > k;
int cmp (rac a, rac b){
if (a.f==b.f){
if (a.ku>b.ku) return 1;
return 0;
}
if (a.f>b.f) return 1;
return 0;
}
int main(){
int n,m; cin >> n;
for (int i=0; i<n; i++) {
int c,f,v; cin >> c >> f >> v; v=(-v);
rac x; x.ku=c; x.f=f; x.v=v;
k.push_back(x);
}
cin >> m;
for (int i=0; i<m; i++) {
int c,f,v; cin >> c >> f >> v; c=(-c);
rac x; x.ku=c; x.f=f; x.v=v;
k.push_back(x);
}
long long int sol=0;
sort (k.begin(), k.end(), cmp);
for (int j=1; j<2010*50; j++) dp[0][j]=-1e18;
for (int i=0; i<k.size(); i++) {
for (int j=0; j<2010*50; j++) {
if (j<k[i].ku) dp[1][j]=dp[0][j];
else if (j-k[i].ku>=2010*50) dp[1][j]=dp[0][j];
else dp [1][j] = max (dp[0][j-k[i].ku]+k[i].v, dp[0][j]);
}
for (int j=0; j<2010*50; j++) dp[0][j]=dp[1][j];
}
for (int j=0; j<2010*50; j++) sol=max (sol, dp[0][j]);
cout << sol;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<rac>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i=0; i<k.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... |