이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
long long n,m,c,f,value,c2,f2,value2,dp[2][10005],core,cost,type,fraud;
vector<tuple<long long,long long,long long,long long> > v;
int main()
{
scanf("%lld",&n);
for(int i=1;i<=n;i++)
{
scanf("%lld%lld%lld",&c,&f,&value);
v.push_back({f,2,value,c});
}
scanf("%lld",&m);
for(int i=1;i<=m;i++)
{
scanf("%lld%lld%lld",&c2,&f2,&value2);
v.push_back({f2,1,value2,c2});
}
v.push_back({-1,-1,-1,-1});
sort(v.begin(),v.end());
for(int i=0;i<=1;i++)
{
for(int j=0;j<=10000;j++)
{
dp[i][j]=-1e18;
}
}
dp[0][0]=0;
for(int i=1;i<v.size();i++)
{
fraud=get<0>(v[i]);
core=get<3>(v[i]);
cost=get<2>(v[i]);
type=get<1>(v[i]);
//printf("%d %d %d %d\n",fraud,core,cost,type);
for(int j=0;j<=10000;j++)
{
dp[i%2][j]=-1e18;
}
for(int j=0;j<=10000;j++)
{
if(type==1)
{
if(j+core<=10000)
{
dp[i%2][j+core]=max(dp[i%2][j+core],dp[1-(i%2)][j]+cost);
}
}else
{
dp[i%2][max(j-core,(long long)0)]=max(dp[i%2][max(j-core,(long long)0)],dp[1-(i%2)][j]-cost);
}
}
for(int j=0;j<=10000;j++)
{
dp[i%2][j]=max(dp[i%2][j],dp[1-(i%2)][j]);
}
/*printf("%d\n",i);
for(int j=0;j<=20;j++)
{
printf("%lld ",dp[i%2][j]);
}
printf("\n");*/
}
printf("%lld\n",dp[(n+m)%2][0]);
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<long long int, long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=1;i<v.size();i++)
| ~^~~~~~~~~
clo.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
7 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
clo.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%lld%lld%lld",&c,&f,&value);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%lld",&m);
| ~~~~~^~~~~~~~~~~
clo.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%lld%lld%lld",&c2,&f2,&value2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |